我正在尝试创建一个闪亮的网页,它将有两个不同的主面板和侧面板。因此,当在sidebarPanel中选择“Case A”时,我想要一个具有特定tabsetPanel的特定mainPanel,如果我选择“Case B”,则会有所不同。阅读完文档后,我陷入了困境:
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) {
})
我收到此错误:
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
任何想法我都缺少什么?
答案 0 :(得分:6)
事实证明我正在使用这个命名法作为一个例子:
condition(input.plotType == 'Case B')
如果我把它改成这个,那么它可以工作:
condition = "input.plotType=='Case B'"