Hi,
Welcome to the RStudio community!
Reactive expression are only evaluated when they are needed. It is hard to guess from just this piece of code, but one thing that is a bit weird is you seem to be updating plots (output$plot_age, output$plot_age_zoomed) without using a renderPlot() function.
The observe is not the best reactive wrapper in this case, you would want to either make a reactive variable or put code in the render plot function.
library(shiny)
ui <- fluidPage(
actionButton('myButton', "click"),
plotOutput("plot1"),
plotOutput("plot2")
)
server <- function(input, output) {
dataPlot1 = reactive({
input$myButton
plot(data.frame(x = 1:5, y = runif(5)))
})
output$plot1 = renderPlot({
dataPlot1()
})
output$plot2 = renderPlot({
input$myButton
plot(data.frame(x = 1:5, y = runif(5)))
})
}
shinyApp(ui, server)
Please provide a reprex if this is not what you are looking for. Shiny debugging and reprex guide
Hope this helps,
PJ