2013-11-01 14 views
6

Tôi đang cố gắng tạo một trang web sáng bóng sẽ có hai bảng chính và mặt khác nhau. Vì vậy, khi chọn "Case A" trong sidebarPanel, tôi muốn một mainPanel cụ thể với một tabsetPanel cụ thể, điều này sẽ khác nếu tôi chọn "Case B". Sau khi đọc các tài liệu hướng dẫn, tôi đã bị mắc kẹt vào thời điểm này:Rstudio sáng bóng có điều kiệnPanel cho 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) { 
}) 

Tôi nhận được lỗi này:

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 

Bất kỳ ý tưởng nào tôi bị thiếu?

Trả lời

5

Hóa ra tôi đang chụp một ví dụ sử dụng thuật ngữ này:

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

trong khi nếu tôi thay đổi nó với điều này, sau đó nó hoạt động:

condition = "input.plotType=='Case B'" 
Các vấn đề liên quan