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'"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With