2013-11-01 2 views
6

Я пытаюсь создать блестящую веб-страницу, которая будет иметь две разные основные и боковые панели. Поэтому, выбирая «Случай A» в sidebarPanel, я хочу конкретную mainPanel с определенной tabsetPanel, которая будет отличаться, если я выберу «Случай B». После прочтения документации, я застрял в этой точке:Rstudio shiny conditionalPanel for mainPanel

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 

Любые идеи, что мне не хватает?

ответ

5

Оказывается, я принимал пример использования этой номенклатуры:

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

в то время как если бы я изменить его на это, то он работает:

condition = "input.plotType=='Case B'" 
Смежные вопросы