具有互動的 textOutput
假設你在美國一間睡眠診所工作。為了了解美國人的睡眠衛生習慣,你進行了一項問卷調查。現在你已有資料,想要彙整並呈現結果。
你不打算交出靜態報告,而是決定用互動式應用程式,讓受眾更投入。
首先,你希望使用者在體驗中先輸入她所居住的城市。你要讓文字輸出會依照使用者輸入而更新。
為此,你會使用 textInput() 函式。
本練習屬於課程
使用 shinydashboard 建立儀表板
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
ui <- fluidPage(
titlePanel("Sleeping habits in America"),
# Add textInput and label it as "city label"
___(___,
"Which city do you live in?",
# Leave the value blank and set the placeholder as "Singapore"
value = ___, placeholder = ___))
server <- function(input, output) {
}
shinyApp(ui, server)