Goal: To load one data frame from an RData my user specifies.
Problem: I keep getting the following warning and error.
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
Can anyone help? Isn't the parameter env=e in the LoadStructure function enough to pass on the environment value? Thanks so much!
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)
}
}
NOTE: The code above is based on the following thread Get specific object from Rdata file