【发布时间】:2017-10-16 05:31:50
【问题描述】:
给定的脚本创建附加的快照。它是使用 R 中的 DT 包创建的表。我想在表上方制作菜单,以便通过在第一个 SelectInput 中选择输入“A”,我得到第二个 selectInput有两个滑块,在第一个 SelectInput 中选择“B”时,我应该只得到第二个 SelectInput 而没有滑块。桌面虹膜无需更改。请帮忙,谢谢。
## app.R ##
library(shiny)
library(shinydashboard)
library(DT)
#Declaring the UI
ui <- fluidPage(
titlePanel("Interactive Menu"),
# Create a new Row in the UI for selectInputs
fluidRow(
column(3,
selectInput("names",
"Customer:",
c("A","B"))
)),
fluidRow(
column(4,
selectInput("names",
"Customer:",
c(as.character(iris$Species)))
),
column(4,
sliderInput("slide", "Select the slider one",
min = 75, max = 100,
value = 75, step = 5)
),
column(4,
sliderInput("city", "Select the slider two",
min = 60, max = 100,
value = 60, step = 10)
)),
# Create a new row for the table.
fluidRow(
DT::dataTableOutput("table1")
)
)
#Declaring the Server
server <- function(input, output) {
# Filter data based on selections
output$table1 <- renderDataTable({
datatable(iris, options = list(
searching = FALSE,
pageLength = 5,
lengthMenu = c(5, 10, 15, 20)
))
})
}
shinyApp(ui, server)
【问题讨论】:
-
嗨哈迪克,谢谢,我已经研究过这个功能,我的问题是,我们可以像这个链接所说的标签集条件面板一样,用条件面板实现 selectInput,如果您有一个工作示例,请分享。
-
您可以使用
conditionalPanel或uiOutput和renderUI。 -
我想使用 conditialPanel 添加多个 selectInputs 和滑块,你碰巧有一个工作示例的好链接吗?
-
非常感谢 SBista 和 Hardik 的帮助。