[R] load object
Fernando Henrique Ferraz P. da Rosa
feferraz at ime.usp.br
Fri Jan 14 19:16:52 CET 2005
Weiwei Shi writes:
> Hi,
> I happen to re-write my codes to save memory and my
> approach is write my obj into file first and later I
> load it.
>
> However, it seems like:
> load(filename) can load the object but the function
> returns the name of the object instead of the
> reference to it. For example, I have an object called
> r0.prune, which is saved by
> save(r0.prune, file='r0.prune')
>
> and later, I want to load it by using:
> load('r0.prune')
> but I need to put the reference to the object r0.prune
> into a var or a list. I tried:
> t<-load('r0.prune'),
> and class(t) gave me a char, which means t stores the
> name of obj instead of the obj itself.
As load() when used interactively will load it into the Global
workspace by default, you can just use get() on it.
r0.prune <- 1:10
save(r0.prune,file='dados.dat')
rm(r0.prune)
t <- get(load('dados.dat'))
t
--
Fernando Henrique Ferraz P. da Rosa
http://www.ime.usp.br/~feferraz
More information about the R-help
mailing list