2013-11-01 16 views
6

Sto provando a creare una pagina Web lucida che avrà due pannelli principali e laterali diversi. Quindi, quando si sceglie "Caso A" nel sidebarPanel, voglio un mainPanel specifico con un tabset specifico, che sarà diverso se scelgo "Caso B". Dopo aver letto la documentazione, mi sono bloccato a questo punto:Rstudio shiny condizionalePanel per 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) { 
}) 

sto ottenendo questo errore:

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 

Qualche idea di cosa mi sto perdendo?

risposta

5

Si scopre stavo prendendo un esempio utilizzando questa nomenclatura:

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

mentre se lo cambio a questo, allora funziona:

condition = "input.plotType=='Case B'"