带有交互的 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)