我希望能够将用户选择保存为字符向量,以便在后续分析中用作输入(
示例:
my_choices
下拉菜单)。如何保存所选内容?示例:
library("shiny")
library("shinyWidgets")
my_choices <- c(
"2018Q1","2018Q2","2018Q3", "2018Q4", "2019Q1", "2019Q2")
ui <- fluidPage(
pickerInput(
inputId = "id",
label = "SELECT PERIOD:",
choices = my_choices,
selected = NULL,
multiple = TRUE,
options = list(
`actions-box` = TRUE, size = 15, `selected-text-format` = "count > 3"
),
choicesOpt = list(
content = stringr::str_trunc(my_choices, width = 75)
)
),
verbatimTextOutput(outputId = "res")
)
server <- function(input, output, session) {
output$res <- renderPrint(input$id)
}
shinyApp(ui = ui, server = server)