【问题标题】:Shiny R checkboxGroupInput selected allShiny R checkboxGroupInput 选中了所有
【发布时间】:2016-07-05 09:03:01
【问题描述】:

我的 Shiny 应用中有一个 checkboxGroupInput,代码如下:

checkboxGroupInput("sexe", "Sexe:",
c("Masculin" = "mas","Féminin" = "fem"))

我的问题是如何在首次加载时检查它们?

知道我已经尝试过 selected=c 但没有成功

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    使用selected = c("mas","fem")

    例如

    library(shiny)
    library(shinydashboard)
    
    ui <- dashboardPage(
      dashboardHeader(),
      dashboardSidebar(),
      dashboardBody( checkboxGroupInput("sexe","Sexe:", 
                                        choices = c("Masculin" = "mas", "Femenin" = "fem"),
                                        selected = c("mas","fem")))
    )
    
    server <- function(input, output){
    
    }
    
    shinyApp(ui, server)
    

    【讨论】:

    • 也可能更好:创建choise_list=list("Masculin" = "mas", "Femenin" = "fem"),然后使用choices = choise_list, selected = choise_list(可能更好地添加到答案中)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-14
    • 2019-06-29
    • 1970-01-01
    • 1970-01-01
    • 2017-05-03
    • 2018-10-16
    相关资源
    最近更新 更多