Rstudio brilliant conditional panel for mainPanel

I am trying to create a shiny web page that will have two different main and side panels. Therefore, choosing "Case A" in the sidebarPanel, I want a specific mainPanel with a specific tabsetPanel, which will be different if I select "Case B". After reading the documentation, I was 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 get 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 I am missing?

+6
source share
1 answer

Turns out I used an example of this nomenclature:

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

whereas if I change it to this, then it will work:

 condition = "input.plotType=='Case B'" 
+5
source

Source: https://habr.com/ru/post/957174/


All Articles