使用shinywidgets选择器输入,我正在尝试使用下拉列表。下面是代码。谁能告诉我如何在显示输入中显示文本总数,当用户选择所有输入时。我可以显示计数,但不是文本总数。
library("shiny")
library("shinyWidgets")
ui <- fluidPage(
column(
width = 4,
pickerInput(
inputId = "id", label = "Choices :",
choices = c("Banana", "Blueberry", "Cherry", "Coconut", "Grapefruit",
"Kiwi", "Lemon", "Lime", "Mango", "Orange", "Papaya"),
options = list(`actions-box` = TRUE, `selected-text-format` = "count > 2",
`count-selected-text` = "{0}/{1} fruits"),
multiple = TRUE
)
)
)
server <- function(input, output) {
output$res <- renderPrint({
input$id
})
}
shinyApp(ui = ui, server = server)发布于 2018-05-31 15:02:53
像这样的东西?
编辑:根据请求I just want the text "TOTAL" when everything is selected
library("shiny")
library("shinyWidgets")
mychoices <- c("Banana", "Blueberry", "Cherry", "Coconut", "Grapefruit","Kiwi", "Lemon", "Lime", "Mango", "Orange", "Papaya")
ui <- fluidPage(
column(
width = 4,
pickerInput(
inputId = "id", label = "Choices :",
choices = mychoices,
options = list(`actions-box` = TRUE, `selected-text-format` = paste0("count > ", length(mychoices)),`count-selected-text` = "TOTAL"),
multiple = TRUE
)
)
)
server <- function(input, output) {}
shinyApp(ui = ui, server = server)

https://stackoverflow.com/questions/50616346
复制相似问题