R Shiny pickerInput 选择所有文本

SNT*_*SNT 1 r shiny

使用shinywidgets pickerinput 我正在尝试使用下拉列表。下面是代码。有人能告诉我当用户选择所有输入时如何在显示输入中显示文本总数。我可以显示计数而不是文本总数。

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)
Run Code Online (Sandbox Code Playgroud)

Por*_*hop 6

像这样的东西?

编辑:根据要求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)
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明