0

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

Ketty
  • 811
  • 10
  • 21
  • `LoadStructure<-function(suffix="temp", env)`. Your definition of the function only has one argument, I've added another one named `env`. You could, alternatively use the dots argument, but you do need more than just `suffix`. – Rui Barradas Aug 28 '17 at 20:47
  • Your LoadStructure function doesn't have a parameter named `env=` and yet you are passing it one. I think you want that to be a parameter that you pass to `get()`? – MrFlick Aug 28 '17 at 20:47
  • I added envir as LoadStructure parameter and still got the same error. Any other idea? Thanks! NOTE: I edited my original code. – Ketty Aug 29 '17 at 14:41
  • Seems unlikely you would get the exact same error message. At least the name of the ignored parameter should have changed. – MrFlick Aug 30 '17 at 18:16

0 Answers0