简体   繁体   中英

Rstudio shiny conditionalPanel for mainPanel

I am trying to create a shiny web page that will have two different main and side panels. So when choosing "Case A" in the sidebarPanel, I want a specific mainPanel with a specific tabsetPanel, that will be different if I choose "Case B". After reading the documentation, I got stuck at this point:

ui.R:

shinyUI(pageWithSidebar(
  headerPanel("This is a Shiny page"),
  sidebarPanel(
     selectInput(
        "plotType", "Plot Type",
        c("Case A","Case B")
         )
  ),
  mainPanel(
    conditionalPanel(
      condition(input.plotType == 'Case A'),
       tabsetPanel(
         tabPanel("A1",
           textOutput("This is conditionalPanel A1")
                  ),
         tabPanel("A2",
           textOutput("This is conditionalPanel A2")
                  )
         )
     ),
    conditionalPanel(
      condition(input.plotType == 'Case B'),
      tabsetPanel(
        tabPanel("B1",
          textOutput("This is conditionalPanel B1")
                  ),
        tabPanel("B2",
          textOutput("This is conditionalPanel B2")
                  )
      )
    )
  )
))

server.R:

shinyServer(function(input, output) {
})

I am getting this error:

Listening on port 50709
Error in tag("div", list(...)) : could not find function "condition"
Calls: runApp ... tag -> conditionalPanel -> div -> <Anonymous> -> tag
Error in setwd(orig.wd) : cannot change working directory
Calls: runApp ... conditionalPanel -> div -> <Anonymous> -> tag -> setwd
Execution halted

Any ideas what am I missing?

It turns out I was taking an example using this nomenclature:

condition(input.plotType == 'Case B')

whereas if I change it to this, then it works:

condition = "input.plotType=='Case B'"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM