shiny UI page to show different output based on different conditions

I just want to check with the RStudio and Shiny experts to see if my below needs is feasible to implement.
On a Shiny page, say based on Condition==A, Shiny would display its normal UI elements.
But when Condition==B, I would like that same Shiny page to display instead a big image itself ['saying No Data is Available'], and those normal UI elements would be invisible.

Would the above be possible? If yes, what changes do I need to cater for? You can see that the Condition may change from one hour or one minute to the next Condition, so that Shiny page must be able to toggle itself automatically based on its condition. It seems to me that the control of its UI display need to be on the ui.R side, but putting

 invalidateLater(60*1000)  ## every minute

to check its condition will NOT work on the ui.R

Any good suggestions?

hi @tanthiamhuat, you can make your whole UI dynamic using renderUI
Inside the renderUI you can put your condition


I think you did not get my requirements right. It is not as straight forward as just using renderUI.

It needs something like this:


ui <- fluidPage(
  selectInput("num", "Choose a number", 1:10),

server <- function(input, output, session) {
  sqr <- reactive({
    sqrt(as.numeric(input$num)) %% 1 == 0

output$sout <- renderUI({
  "That's a perfect square!"

shinyApp(ui = ui, server = server)

hmm... both of you are suggesting renderUI.

But for my case, my normal UI elements in fact is quite complex (contain valueBoxOutput,uiOutput,radioButtons,airDatepickerInput,imageOutput,dygraphOutput,textOutput) based on fluidPage and fluidRow.

And based on different condition, I want to replace all the above UI elements with a big image.
Is renderUI able to achieve it? I read that conditionalPanel is more suitable for my case.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.