在闪亮的,我想使用相同的数据集来生成和显示图形和表格,并以csv格式下载表格中的数据 .
我首先在服务器下加载数据表,代码如下
DTGlobal <- readRDS("bigfile")
我闪亮的selectInput()设置一些用户输入,如下所示
selectInput(inputId = "ScenarioName", label = "xxx", choices = scenarioNames)
目前,我在 renderTable()
和 renderPlot()
中创建了相同的特定于场景的数据集
scenarioName <- input$availabilityScenarioName
DTlocal <- data.table::copy(DTGlobal[scenario %in% scenarioName)
add some further manipulations of DTlocal here
到目前为止,我已经通过基本上复制 renderPlot()
和 renderTable()
中的代码来完成图表和表格 . 我可以用 downloadHandler()
做同样的事情 . 但我想知道是否有某种方法可以在服务器级别创建数据,然后我可以在下面的函数中访问 . 我想我可以在 renderPlot()
中使用 newDTGlobal <<- DTlocal
(首先称之为),但我认为这会让所有人都可以使用 . 如果他们运行相同的 renderPlot()
将消灭我的数据 .
1 回答
弄清楚如何使用反应技术就可以了 . 这是我正在做的事情的代码片段 . 它从输入获取变量值,并使用该信息生成数据表 .
下一段代码显示了我如何使用它(两个代码块都在服务器中) . 相关的一点是
data.foodAvail()
. 这是上面生成的值,该值特定于用户选择的输入值 .需要data.table副本,因为
data.foodAvail()
由spiderGraphData函数中涉及:=
的数据表操作更改 .