กรณีศึกษา: การสร้างเว็บแอปพลิเคชันด้วย Shiny ใน R
Dean Attali
Shiny Consultant
reactive() และ input$ มีความเป็น reactivex <- reactive({
y() * input$num1 * input$num2
})
isolate() เพื่อไม่ให้สร้าง reactive dependencyisolate() เปลี่ยนแปลง จะไม่มีอะไรเกิดขึ้นx <- reactive({
y() * isolate({ input$num1 }) * input$num2
})
x <- reactive({
y() * isolate({ input$num1 * input$num2 })
})
บางครั้งต้องการ isolate ทุก reactive
x <- reactive({
isolate({
y() * input$num1 * input$num2
})
})
ต้องการวิธีกระตุ้นให้ x รันใหม่ตามต้องการ
actionButton(inputId, label, ...)

# After clicking on a button twice
str(input$button)
int 2
การเข้าถึงค่า input ของปุ่มใน server จะกระตุ้น reactivity
เพิ่มปุ่มใน UI
actionButton(inputId = "calculate_x", label = "Calculate x!")
เข้าถึงปุ่มเพื่อให้กลายเป็น dependency
x <- reactive({
input$calculate_x
isolate({
y() * input$num1 * input$num2
})
})
กรณีศึกษา: การสร้างเว็บแอปพลิเคชันด้วย Shiny ใน R