2017-04-03 6 views
1

私はシャイニーの初心者です。私はこのコードを持っています。私は3 tabPanelsを作成しました。 Shiny Appを実行すると、すべてのタブにすべての条件セットが表示されます。選択したタブに応じて、条件を満たすアイテムのみが表示されます。私は他の人々が提案したようにアイテムの異なる名前を変更しましたが、それはまだ私の最後に働いていないようです。シャイニー条件付きパネルはすべてのタブのすべての条件を表示します

どのようなヘルプも大いに感謝します。

ui <- fluidPage(

    sidebarLayout(

    sidebarPanel(

     conditionalPanel(
     condition="input.tabselected=='AAA'", 
     selectInput("selectDisease1", 
        label="Select Disease:", 
        choices=c("Disease 1","Disease 2") 
        ), 

     selectInput("selectProduct1", 
        label="Select Products:", 
        choices=product.list, 
        selected=NULL, 
        multiple=TRUE 
        ), 

     selectInput("selectStartDate1", 
        label="Select Start Date:", 
        choices=names(SBI[c(5:num.columns)]), 
        selected = 1 
        ), 

     selectInput("selectEndDate1", 
        label="Select End Date:", 
        names(SBI[c(5:num.columns)]), 
        selected = 1 
        ), 

     submitButton("Submit") 

    ), 

     conditionalPanel(
     condition="input.tabs=='Data'", 
     selectInput("selectDisease2", 
        label="Select Disease:", 
        choices=c("Disease 1","Disease 2") 
     ), 

     selectInput("selectProduct2", 
        label="Select Products:", 
        choices=product.list, 
        selected=NULL, 
        multiple=TRUE 
     ), 

     selectInput("selectStartDate2", 
        label="Select Start Date:", 
        choices=names(SBI[c(5:num.columns)]), 
        selected = 1 
     ), 

     selectInput("selectEndDate2", 
        label="Select End Date:", 
        names(SBI[c(5:num.columns)]), 
        selected = 1 
     ), 

     numericInput("lines2", 
        label="Number of Lines:", 
        value=1 
     ), 

     dateRangeInput('dateRange2', 
         label = paste('Date range input 1:'), 
         separator = " - ", 
         format = "yyyy-mm", 
         startview = 'month' 
     ), 

     submitButton("Submit") 

    ), 

     conditionalPanel(
     condition="input.tabs=='Plot'", 
     selectInput("selectDisease3", 
        label="Select Disease Stage:", 
        choices=c("Disease Stage 1","Disease Stage 2") 
        ), 

     selectInput("selectProduct3", 
        label="Select Products:", 
        choices=product.list, 
        selected=NULL, 
        multiple=TRUE 
        ), 

     selectInput("selectStartDate3", 
        label="Select Start Date:", 
        choices=names(SBI[c(5:num.columns)]), 
        selected = 1 
        ), 

     selectInput("selectEndDate3", 
        label="Select End Date:", 
        names(SBI[c(5:num.columns)]), 
        selected = 1 
        ), 

     numericInput("trends3", 
        label="Number of Linear Trends:", 
        value=1 
        ), 

     dateRangeInput('dateRange3', 
         label = paste('Date range input 1:'), 
         separator = " - ", 
         format = "yyyy-mm", 
         startview = 'month' 
        ), 
     dateRangeInput('dateRange4', 
         label = paste('Date range input 2:'), 
         separator = " - ", 
         format = "yyyy-mm", 
         startview = 'month' 
        ), 

     submitButton("Submit") 

    )  
    ), 

    mainPanel(
     titlePanel("Assessment"), 

     tabsetPanel(

     id = "tabselected", 
     selected = NULL, 

     tabPanel("AAA Disease State", 
       value="AAA", 
       tags$hr(), 
       DT::dataTableOutput("sbirx.view", width = 300) 
       ), 
     tabPanel("Data", 
       value="Data", 
       tags$hr(), 
       DT::dataTableOutput("sbirx.view", width = 300) 
       ), 
     tabPanel("Plot", 
       value="Plot", 
       tags$hr(), 
       DT::dataTableOutput("sbirx.view", width = 300) 
       ) 

    ) 

    ) # end of main panel 

) # end of sidebarLayout 

) # end of fluidpage 

答えて

0

問題は、データテーブルのレンダリングであり、出力は一意である必要があります。 sbirx.viewを1回だけレンダリングすることができます。出力を3回表示する場合は、sbirx.view2sbirx.view3のようなものを割り当ててレンダリングします。また、あなたの応答GGambaに感謝submitButtonを削除し、@GGambaが

tabsetPanel(

id = "tabselected", 

tabPanel("AAA Disease State", 
     value=10, 
     tags$hr() 
     #,DT::dataTableOutput("sbirx.view", width = 300) 
), 
tabPanel("Data", 
     value=20, 
     tags$hr() 
     #,DT::dataTableOutput("sbirx.view", width = 300) 
), 
tabPanel("Plot", 
     value=30, 
     tags$hr() 
     #,DT::dataTableOutput("sbirx.view", width = 300) 
) 

を示唆したようにそれぞれにactionButtonを割り当てる)

+0

それは問題を解決します。ありがとう – aotearoa

+0

@aotearoaこれが解決策だったら答えを受け入れてください –

+0

はい、私はこの問題を解決するために答えを受け入れます。これを調べていただきありがとうございます。すてきな一日を! – aotearoa

0

submitButton()は、パネルの内側に存在する場合conditionalPanelが動作しない問題(多分それは意図しています)があります。

修正するにはactionButton()を使用してください。

サーバーコードを適切に変更する必要があることに注意してください。

+0

。しかし、私はactionButton()を使ってみました。それでも同じ問題です。私はSubmitButton()またはactionButton()を使わずに実行しようとしました。それでも同じ問題です。 – aotearoa

関連する問題