【发布时间】:2017-04-04 16:01:51
【问题描述】:
我是 Shiny 的新手,我有这个代码。我创建了 3 个 tabPanel。当我运行 Shiny 应用程序时 - 它在所有选项卡中显示所有条件集。根据我选择的选项卡,它应该只显示满足条件的项目。就像其他人建议的那样,我已经更改了该项目的不同名称,但它似乎仍然对我不起作用。
非常感谢任何帮助。
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
【问题讨论】: