Nghiên cứu tình huống: Xây dựng ứng dụng web với Shiny trong R
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 = ID duy nhấtlabel = Nhãn mô tả đầu vào... = Tham số bổ sung theo loại đầu vàoHai bước:
Tạo chỗ trống cho đầu ra (trong UI)
ui <- fluidPage(
"Plot goes here:",
plotOutput(outputId = "my_plot")
)
Viết mã R để sinh đầu ra (trong 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> để lấy giá trị đầu vàoNghiên cứu tình huống: Xây dựng ứng dụng web với Shiny trong R