checkboxInput 與 checkboxGroupInput
現在你要嘗試另一個與核取方塊輸入有關的例子。就像影片中提到的,如果只需要單一核取方塊,可以使用 checkboxInput();如果需要多個核取方塊,則使用 checkboxGroupInput()。
在你的 shinyApp 中,你可能也希望使用者能選擇一週中的日類型,因為人們在不同日子可能有不同的睡眠習慣。舉例來說,如果隔天沒有上學或上班,你也許會睡得稍晚一點。
在這個練習中,你會讓使用者從以下選項中擇一:
- 「All days」
- 「Nonholiday weekdays」
- 「Weekend days and holidays」
shiny 函式庫已為你載入。
本練習屬於課程
使用 shinydashboard 建立儀表板
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
ui <- fluidPage(
titlePanel("Sleeping habits in America"),
# Add a checkbox input
___("checkboxlabel",
# Set the name and initial value
___, value = ___))
server <- function(input, output, session) {
}
shinyApp(ui, server)