Created
December 6, 2012 03:48
-
-
Save jeffreyhorner/4221630 to your computer and use it in GitHub Desktop.
simpleTab with visible tab id
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
shinyServer(function(input, output) { | |
cat('shinyServer called\n',file=stderr()) | |
output$foo <- reactivePrint(function(){ | |
cat('output$foo called\n',file=stderr()) | |
input | |
}) | |
runIfVisible <- function(visibleTab,val,expr){ | |
if (visibleTab==val) | |
return(eval(expr,parent.frame())) | |
else | |
return(NULL) | |
} | |
output$afunc <- reactivePrint(function() { | |
runIfVisible(input$visibleTab,'A',{ | |
cat('output$afunc updated\n',file=stderr()) | |
input$n | |
}) | |
}) | |
output$bfunc <- reactivePrint(function() { | |
runIfVisible(input$visibleTab,'B',{ | |
cat('output$bfunc updated\n',file=stderr()) | |
Sys.sleep(4) | |
input$n | |
}) | |
}) | |
output$plot <- reactivePlot(function(){ | |
runIfVisible(input$visibleTab,'Plot',{ | |
cat('output$plot updated\n',file=stderr()) | |
plot(rnorm(input$n)) | |
}) | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
shinyUI(pageWithSidebar( | |
# Application title | |
headerPanel("Tabsets"), | |
sidebarPanel( | |
sliderInput("n", | |
"Number of observations:", | |
value = 500, | |
min = 1, | |
max = 1000) | |
), | |
mainPanel( | |
tabsetPanel( | |
tabPanel("A", verbatimTextOutput("afunc")), | |
tabPanel("B", verbatimTextOutput("bfunc")), | |
tabPanel("Plot",plotOutput('plot')), | |
id='visibleTab' | |
) | |
) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment