I want the variable x's value to be increased by 1 each time the actionButton is increased, see below reproducible code for example. However the code inside observeEvent are isolated, and the value of x won't get updated incrementally.
library(shiny)
ui <- fluidPage(
actionButton("plus","+1"),
textOutput("value")
)
server <- function(input, output, session) {
x = 1
observeEvent(input$plus,{
x = x+1
output$value = renderText(x)
})
}
shinyApp(ui, server)