首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >R Shiny pickerInput选择所有文本

R Shiny pickerInput选择所有文本
EN

Stack Overflow用户
提问于 2018-05-31 11:47:42
回答 1查看 2.2K关注 0票数 1

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

代码语言:javascript
复制
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)
EN

回答 1

Stack Overflow用户

发布于 2018-05-31 15:02:53

像这样的东西?

编辑:根据请求I just want the text "TOTAL" when everything is selected

代码语言:javascript
复制
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)

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50616346

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档