在闪亮的情况下,我需要选择一个数字范围,并将其用作另一个pickerInput中的选择。
首先我有:
sliderTextInput(
inputId = "size.range",
label = "Choose a value:",
choices = c(1:100),
selected =c(18,24),
grid = TRUE )
在我拥有之后:
pickerInput(
inputId = "sample.histoall",
label = "Selected Size",
choices = list( XXXXXX ),
options = list(`actions-box` = TRUE),
multiple = TRUE)
用我替换XXXXXX的内容?
答案 0 :(得分:1)
您可以观察数字范围的值,并在每次更改时更新pickerInput
。您可以选择在pickerInput
中显示两个返回值或返回值之间的范围。我在下面的示例中添加了这两个选项。
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
sliderTextInput(
inputId = "size.range",
label = "Choose a value:",
choices = c(1:100),
selected =c(18,24),
grid = TRUE ),
pickerInput(
inputId = "sample.histoall",
label = "Selected Size",
choices = list( '' ),
options = list(`actions-box` = TRUE),
multiple = TRUE),
pickerInput(
inputId = "sample.histoall.range",
label = "Selected Size",
choices = list( '' ),
options = list(`actions-box` = TRUE),
multiple = TRUE)
)
server <- function(input, output, session) {
observe({
updatePickerInput(session, 'sample.histoall', choices=input$size.range)
updatePickerInput(session, 'sample.histoall.range', choices=as.numeric(input$size.range[1]):as.numeric(input$size.range[2]))
})
}
shinyApp(ui, server)