กรณีศึกษา: การสร้างเว็บแอปพลิเคชันด้วย Shiny ใน 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 ที่ไม่ซ้ำกันlabel = ข้อความอธิบาย input... = พารามิเตอร์เพิ่มเติมเฉพาะ input2 ขั้นตอน:
สร้าง placeholder สำหรับ output (ใน UI)
ui <- fluidPage(
"Plot goes here:",
plotOutput(outputId = "my_plot")
)
เขียนโค้ด R เพื่อสร้าง output (ใน 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> เพื่อเข้าถึงค่าของ inputกรณีศึกษา: การสร้างเว็บแอปพลิเคชันด้วย Shiny ใน R