r - conditionalPanel in Shiny not working -
i trying use conditionalpanel display message when file being loaded. however, panel not disappearing once condition true. have created reproducible code below:
server.r
library(shiny) print("loading start") print(paste("1->",exists('fgram'))) fgram <- readrds("data/ugram.rds") print(paste("2->",exists('fgram'))) print("loading end") shinyserver( function(input, output, session) { })
ui.r
library(shiny) shinyui( fluidpage( sidebarlayout( sidebarpanel( h4("side panel") ) ), mainpanel( h4("main panel"), br(), textoutput("first line of text.."), br(), conditionalpanel(condition = "exists('fgram')", html("please wait!! <br>app loading, may take while....")), br(), h4("last line of text..") ) ) )
conditions supplied conditionalpanel
executed in javascript environment, not r environment, , therefore cannot reference or inspect variables or functions in r environment. solution situation use uioutput
, in example below.
myglobalvar <- 1 server <- function(input, output) { output$condpanel <- renderui({ if (exists('myglobalvar')) html("please wait!! <br>app loading, may take while....") }) } ui <- fluidpage({ uioutput('condpanel') }) shinyapp(ui=ui, server=server)
Comments
Post a Comment