案例研究:使用 R 的 Shiny 构建 Web 应用
Dean Attali
Shiny Consultant



ui <- fluidPage(
textInput(inputId = "name", label = "Enter your name",
value = "Dean"),
numericInput(inputId = "sibs", label = "How many siblings?",
value = 4, min = 0)
)
*Input(inputId, label, ...)inputId = 唯一IDlabel = 输入说明文本... = 其他与输入相关的参数两步:
创建输出占位符(在 UI 中)
ui <- fluidPage(
"Plot goes here:",
plotOutput(outputId = "my_plot")
)
编写 R 代码生成输出(在 server 中)
server <- function(input, output) {
# Code for building outputs
}
inputoutputui <- fluidPage( numericInput("num", "Number of rows", value = 10, min = 0), tableOutput("my_table") )server <- function(input, output) { output$my_table <- renderTable({ head(iris, n = input$num) }) }
renderPlot(), renderText() 等)output$<outputId>input$<inputId> 访问输入值案例研究:使用 R 的 Shiny 构建 Web 应用