rrdata

Loading RData files within a Rscript


I am trying to load an .Rdata file within a rscript manipulate the data etc.

when I do this in R console int works:

load("R.RData")
x<-Data ##Data is the object in R.data file

but when I put this in a script, I get errors:

 object of type 'environment' is not subsettable

any ideas?


Solution

  • You can create an environment and load the data into the environment.

    tmpenv <- new.env()
    load("R.RData", envir=tmpenv)
    x <- tmpenv$Data