目标:从用户指定的RData加载一个数据框。
问题:我一直收到以下警告和错误。
Warning: Error in LoadStructure: unused argument (env = e)
Stack trace (innermost first):
66: load_RData_f [C:\Users\Shiny/server.R#131]
65: observeEventHandler [C:\Users\Shiny/server.R#148]
1: runApp
ERROR: [on_request_read] connection reset by peer
有人可以帮忙吗? LoadStructure函数中的参数 env = e 是否足以传递环境值?非常感谢!
load_RData_f <- function(){
e <- local({load(input$RData_file$datapath); environment()})
tools:::makeLazyLoadDB(e, input$RData_file$name)
lazyLoad(eval(input$RData_file$name, envir = e))
# Display existing data frames in workspace
cat(names(which(sapply(e, is.data.frame))),sep="\n")
LoadStructure("temp", envir = e)
}
LoadStructure<-function(suffix="temp", envir) {
if (tryCatch(is.matrix(get(paste0("node_",suffix)), envir=envir), error=function(cond) FALSE) == FALSE) {
load_error <<- as.numeric("1")
cat("The structure is not recognized. Please check the structure name.\n")
} else {
MeasureType <<- get(paste0("MeasureType_",suffix), envir=envir)
data <<- get(paste0("data_",suffix) , envir=envir)
}
}
注意:上面的代码基于以下线程 Get specific object from Rdata file