【问题标题】:Select multiple choices in selectInput() when selectize=F当 selectize=F 时在 selectInput() 中选择多个选项
【发布时间】:2021-04-11 12:39:26
【问题描述】:

selectize=FselectInput()如何选择多个项目?

library(shiny)
library(shinydashboard)
shinyApp(
  ui = dashboardPage(
    header = dashboardHeader(),
    sidebar = dashboardSidebar(),
    body = dashboardBody(
      uiOutput("box1")

    ),
    title = "DashboardPage"
  ),
  server = function(input, output) {
    output$box1<-renderUI({

        box(

          selectInput(inputId = "in", label = "Choose", choices = c('Short','A very short sentence.'), 
                      selectize = F,multiple=T, size = 5, width = "150px")
          
        )
    })
  }
)

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    您所拥有的是允许多项选择。 如果您添加它,您可能会更清楚地看到它(即使它是临时的) 在uiOutput("box1") 之后添加verbatimTextOutput(outputId = "res")(不要忘记添加逗号)并在server 中的output$box1 之后添加output$res &lt;- renderPrint({input$`in`})

    library(shiny)
    library(shinydashboard)
    shinyApp(
      ui = dashboardPage(
        header = dashboardHeader(),
        sidebar = dashboardSidebar(),
        body = dashboardBody(
          uiOutput("box1"),                       # comma added here
          verbatimTextOutput(outputId = "res")    # this is added
        ),
        title = "DashboardPage"
      ),
      server = function(input, output) {
        output$box1 <- renderUI({
          box(
            selectInput(inputId = "in", label = "Choose", choices = c('Short','A very short sentence.'), 
                        selectize = F,multiple=T, size = 5, width = "150px")
          )# ends the box
        }) # ends output$box1
        output$res <- renderPrint({input$`in`})  # this is added here - since 'in' is a keyword I would suggest a different id...
      } # ends server call
    ) # ends shinyApp
    

    【讨论】:

      猜你喜欢
      • 2014-11-04
      • 1970-01-01
      • 2021-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-18
      相关资源
      最近更新 更多