[R] Importing a dataset
Gabor Csardi
csardi at rmki.kfki.hu
Fri Sep 21 16:01:40 CEST 2007
I don't know a way of loading parts of an .RData file either,
but another solution is to use the envir argument of load to
load the data into a new environment:
> x <- 1
> y <- rnorm(3)
> save.image("tmp.RData")
> rm(x)
> rm(y)
> load("tmp.RData", env <- new.env())
> get("x", env)
[1] 1
> get("y", env)
[1] -0.1105102 0.6923334 1.5506114
> rm(env)
Gabor
On Fri, Sep 21, 2007 at 02:52:21PM +0100, S Ellison wrote:
> I don't know a short way, but this worked when I tried it. Maybe there's a clue in there somewhere?
>
> get1<-function(fname, varname) {
> load(fname)
> get(varname)
> }
>
> x<-1
> y<-rnorm(3)
>
> save.image("temp.RData")
>
> rm(x)
> rm(y)
>
> get1("temp.Rdata","x")
>
> get1("temp.Rdata","y")
>
>
> Steve E
>
> >>> "Marco Venanzi" <marvena at tin.it> 17/09/2007 12:38:24 >>>
> Hi,how can I load a dataset from another file R.Data,without importing all the objects (functions and other datasets) contained in that file?Thanks, Marco
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> *******************************************************************
> This email contains information which may be confidential and/or privileged, and is intended only for the individual(s) or organisation(s) named above. If you are not the intended recipient, then please note that any disclosure, copying, distribution or use of the contents of this email is prohibited. Internet communications are not 100% secure and therefore we ask that you acknowledge this. If you have received this email in error, please notify the sender or contact +44(0)20 8943 7000 or postmaster at lgcforensics.com immediately, and delete this email and any attachments and copies from your system. Thank you.
>
> LGC Limited. Registered in England 2991879.
> Registered office: Queens Road, Teddington, Middlesex TW11 0LY, UK
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Csardi Gabor <csardi at rmki.kfki.hu> MTA RMKI, ELTE TTK
More information about the R-help
mailing list