2017-07-25 7 views
0

条件付きパネルに問題があります。 sidebarPanelにあるRadioButtonの選択肢に応じて、sidebarPanelにDateRangeまたはSliderInputのいずれかを表示したいとします。光沢のある条件パネルが更新されない

あなたは例の下に実行しようとする場合は、次のエラーメッセージで失敗します:あなたがいずれかをコメントアウトした場合は仮引数「条件」は、複数の実際の 引数

にマッチした:

エラー2つの条件のうち、example変数には、選択したオプションによって値aまたはbがあることがわかります。

私は何かが不足していると確信していますが、何が分かりません。私は周りを見回し、私は何か助けになることができませんでした。あなたは2つのconditionalPanelオブジェクト、各条件のための1つを指定する必要が

library(shiny) 

# Server --------------------------------------------- 

server = shinyServer(function(input, output){ 
    output$debug <- renderPrint({ 
    input$example 
    }) 
}) 


# Ui ------------------------------------------------- 

ui = { 
    fluidPage(
    sidebarPanel(
     radioButtons('example', 'Select Examples: ', choices = c('a', 'b'), selected = 'a'), 
     conditionalPanel(
     condition = "input.example == 'a'", 
     dateRangeInput('date', 'Select Date Range:', 
         start = Sys.Date() - 7, 
         end = Sys.Date(), 
         min = '2012-04-01', 
         max = Sys.Date() 
         ) 
     , 
     condition = "input.example == 'b'", 
     sliderInput('date', 'Slide Date Range:', min = 1, max = 90, value = 14, step = 1) 
     ) 
    ), 
    mainPanel(verbatimTextOutput("debug") 
    ) 
)} 


# App ------------------------------------------------ 

shinyApp(ui = ui, server = server) 

おかげ

答えて

0

library(shiny) 

# Server --------------------------------------------- 

server = shinyServer(function(input, output){ 
    output$debug <- renderPrint({ 
    input$example 
    }) 
}) 


# Ui ------------------------------------------------- 

ui = { 
    fluidPage(
    sidebarPanel(
     radioButtons('example', 'Select Examples: ', choices = c('a', 'b'), 
      selected = 'a'), 
    conditionalPanel(
     condition = "input.example == 'a'", 
     dateRangeInput('date', 'Select Date Range:', 
        start = Sys.Date() - 7, 
        end = Sys.Date(), 
        min = '2012-04-01', 
        max = Sys.Date() 
    ) 
), 
    conditionalPanel(
    condition = "input.example = 'b'", 
    sliderInput('date', 'Slide Date Range:', min = 1, max = 90, value = 14, 
      step = 1) 
) 
), 
mainPanel(verbatimTextOutput("debug") 
) 
)} 


# App ------------------------------------------------ 

shinyApp(ui = ui, server = server) 
関連する問題