Rstudio闪亮的conditionalPanel用于主面板

7

我正在尝试创建一个闪亮的网页,其中将有两个不同的主面板和侧面板。因此,在侧边栏面板中选择“Case A”时,我希望有一个特定的主面板和一个特定的选项卡面板,如果我选择“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

你有什么想法我可能忽略了什么?

1个回答

6
原来我正在使用这个术语作为示例:
condition(input.plotType == 'Case B')

如果我将其更改为这样,则可以正常工作:
condition = "input.plotType=='Case B'"

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接