【发布时间】:2015-12-21 22:36:04
【问题描述】:
我很难理解如何在 R Shiny 中使用 isolate() 和 reactive()。
我想实现以下目标:
每当点击“刷新”操作按钮时:
在 data.frame 上执行
subset并且,将此输入我的函数以重新计算值。
子集取决于用户勾选的一组复选框,其中大约有 40 个。我不能让这些复选框“完全反应”,因为该函数需要大约 1.5 秒才能执行。相反,我想让用户有机会选择多个框,然后单击按钮以 (a) 子集和 (b) 再次调用该函数。
为此,我在 server.R 函数中加载了 data.frame:
df1 <- readRDS("D:/././df1.RData")
然后我有我的主要 shinyServer 功能:
shinyServer(function(input, output) {
data_output <- reactive({
df1 <- df1[,df1$Students %in% input$students_selected]
#Here I want to isolate the "students_selected" so that this is only
#executed once the button is clicked
})
output$SAT <- renderTable({
myFunction(df1)
})
}
【问题讨论】:
标签: r shiny reactive-programming