I am creating an application with several tabs, some of which are related to excessive calculations and others that are quickly calculated. An ideal flag might be that allows the user to choose between reactivity or manual update in combination with the Refresh button.
The simple example below illustrates what I am aiming for. It almost works, except for one final update when the “Automatic update” -checkbox box is not checked, which is a pain if the computational intensive tab should be opened. Is there any way around this?
ui.r
library(shiny) shinyUI(fluidPage( titlePanel("Test"), sidebarLayout( sidebarPanel( checkboxInput("autoRefresh", "Automatically refresh", TRUE), actionButton("refresh", "Refresh!"), radioButtons("choice", "Choice of value:", c("10" = 10, "20" = 20)) ), mainPanel( tabsetPanel(type = "tabs", tabPanel("Add random decimals to value", textOutput("value")) ) ) ) ))
server.r
library(shiny) shinyServer(function(input, output) { output$value <- renderText({ input$refresh if(input$autoRefresh == 1) { input$choice } isolate({ output <- runif(1,0,1) + as.numeric(input$choice) }) }) })
Thank you very much in advance!
source share