R 指定复选框的默认初始值

R 指定复选框的默认初始值,r,shiny,R,Shiny,在下面的代码中,有一些复选框。我想强制,以便选中第一个复选框作为初始默认值 对@Stéphane Laurent的回答 ui <- fluidPage( uiOutput("checkbox_GUI_Readers"), textOutput("xxx"), textOutput("txt_user_specifies_reader_IDs") ) server <- function(input, output, session) { output$che

在下面的代码中,有一些复选框。我想强制,以便选中第一个复选框作为初始默认值

对@Stéphane Laurent的回答

ui <- fluidPage(
  uiOutput("checkbox_GUI_Readers"),
  textOutput("xxx"),

  textOutput("txt_user_specifies_reader_IDs")
)

server <- function(input, output, session) {


  output$checkbox_GUI_Readers <- renderUI({
    checkboxGroupInput("R_object_as_the_result_of_check_boxes_for_reader", "Select Reader ID", choices =  seq(1:8 ),
                       select =1 # This specify the initial condition
                       )
  })



  output$txt_user_specifies_reader_IDs <- renderText({
    icons <- paste(input$R_object_as_the_result_of_check_boxes_for_reader, collapse = ", ")
    paste("Select reader IDs:", icons)
  })

  output$xxx <- renderText({
    icons <- input$R_object_as_the_result_of_check_boxes_for_reader 
    paste( str (icons))
  })
}

shinyApp(ui, server)

ui在
checkboxGroupInput
中尝试
selected=“1”
。谢谢,它通过了。在
checkboxGroupInput
中尝试
selected=“1”
。谢谢,它通过了。