R闪亮负载工作区
R shiny load workspace
我正在学习 Shiny,需要一些帮助。
我需要从保存的工作区 (RData) 加载一个非常大的 data.frame。加载后,我需要执行分析并将这些输出到 UI.
我在 server.R 中放置了以下代码,但它没有加载数据然后抛出错误:
shinyServer(function(input, output) {
load("c:/temp/ws1.RData")
output$balance_matrix <- renderTable({
Transaction_history
})
})
> Error in func() : object 'Transaction_history' not found
首先,我做错了什么?
其次,这是加载工作区的最佳位置吗?
第三,我可以在顶部的函数外加载它还是在函数中不可用?
谢谢
与其保存并尝试加载工作区,我建议单独保存文件,例如,
saveRDS(Transaction_history, "C:/temp/ws1.RData")
然后在 Shiny 中加载它,
Transaction_history <- readRDS("C:/temp/ws1.RData")
此方法将单独关注此文件。来自 ?load
文档,
load() replaces all existing objects with the same names in the
current environment (typically your workspace, .GlobalEnv) and hence
potentially overwrites important data.
我正在学习 Shiny,需要一些帮助。
我需要从保存的工作区 (RData) 加载一个非常大的 data.frame。加载后,我需要执行分析并将这些输出到 UI.
我在 server.R 中放置了以下代码,但它没有加载数据然后抛出错误:
shinyServer(function(input, output) {
load("c:/temp/ws1.RData")
output$balance_matrix <- renderTable({
Transaction_history
})
})
> Error in func() : object 'Transaction_history' not found
首先,我做错了什么?
其次,这是加载工作区的最佳位置吗?
第三,我可以在顶部的函数外加载它还是在函数中不可用?
谢谢
与其保存并尝试加载工作区,我建议单独保存文件,例如,
saveRDS(Transaction_history, "C:/temp/ws1.RData")
然后在 Shiny 中加载它,
Transaction_history <- readRDS("C:/temp/ws1.RData")
此方法将单独关注此文件。来自 ?load
文档,
load() replaces all existing objects with the same names in the current environment (typically your workspace, .GlobalEnv) and hence potentially overwrites important data.