【发布时间】:2016-03-18 17:04:55
【问题描述】:
我全新的 Shiny App 有一个带有两个动态 SelectInput() 函数的侧面板。根据哪个面板处于活动状态,应使用相应的 uiOutput("select") 动态 SelectInput。我读到这可以用 conditionalPanel() 来完成 - 但我不知道如何......我发现的例子中没有结合 uiOutput("select")/SelectInput(),都直接在窗格中使用 SelectInput......
请,任何人都可以帮助我,我必须如何更改代码以包含 conditionalPanel() - 如果这是必要的。非常感谢您的任何建议和帮助!!!!
ui.R
shinyUI(fluidPage(
titlePanel('Table Overviews'),
sidebarPanel(
uiOutput("select1"),
br(),
uiOutput("select2")
),
mainPanel(
tabsetPanel(
tabPanel("Panel 1",
fluidRow(
column(6, h4("Tablel"), tableOutput("Table1")),
column(6, div(style = "height:300px")),
fluidRow(
column(6,h4("Table2"), tableOutput("Table2")),
column(6,h4("Table3"), tableOutput("Table3")))
)),
tabPanel("Panel 2",
fluidRow(
column(6, h4("Table4"), tableOutput("Table4")),
column(6, div(style = "height:300px")),
fluidRow(
column(6,h4("Table5"), tableOutput("Table5")),
column(6,h4("Table6"), tableOutput("Table6")))
))
)
服务器.R
shinyServer(function(input,output){
## two different SelectInputs to select from two different lists
output$select1 <- renderUI({
selectInput("dataset1", "Overview1", as.list(files1))
})
output$select2 <- renderUI({
selectInput("dataset2", "Overview2", as.list(files2))
})
## Output of the first SelectInput
output$Table1 <- renderTable({
f1 <- function1(input$dataset1)
f1[[1]]
})
output$Table2 <- renderTable({
f1 <- function1(input$dataset1)
f1[[2]]
})
output$Table3 <- renderTable({
f1 <- function1(input$dataset1)
f1[[3]]
})
# Output of the second SelectInput
output$Table4<- renderTable({
f2 <- function2(input$dataset2)
f2[[3]]
})
output$Table5 <- renderTable({
f2 <- function2(input$dataset2)
f2[[2]]
})
output$Table6 <- renderTable({
f2 <- function2(input$dataset2)
f2[[1]]
})
})
【问题讨论】:
标签: shiny-server shiny