一个空的 shinyApp
到目前为止,您已经了解了 shinyApp 的组成。首先,您可以像视频中演示的那样,先搭建一个空的 shinyApp。
为此,请回忆餐厅的类比:应用的使用者就像顾客,UI 就像顾客所坐的餐桌,server 则像提供帮助的服务员。
在本练习中,您需要识别这些组件并渲染一个空白的 shinyApp。
本练习是课程的一部分
使用 shinydashboard 构建仪表板
练习说明
- 在
titlePanel()函数中将标题设为 "Sleeping habits in America",并将fluidPage()存为ui。 - 将空的自定义函数存为
server。 - 将
ui和server作为参数传入shinyApp()。
交互式实操练习
通过完成这段示例代码来试试这个练习。
library(shiny)
# Add a title and store as ui
___ <- fluidPage(titlePanel(___))
# Store empty custom function as server
___ <- function(input, output){
}
# Enter the arguments for shinyApp()
shinyApp(___, ___)