[R] saving a 'get' object in R
hb at biostat.ucsf.edu
Tue Jun 24 22:50:08 CEST 2014
I recommend to use saveRDS()/readRDS() instead. More convenient and
avoids the risk that load() has of overwriting existing variables with
the same name.
On Tue, Jun 24, 2014 at 1:45 PM, Greg Snow <538280 at gmail.com> wrote:
> I think that you are looking for the `list` argument in `save`.
> save( list=foo, file=paste0(foo, '.Rdata') )
> In general it is best to avoid using the assign function (and get when
> possible). Usually there are better alternatives.
> On Tue, Jun 24, 2014 at 2:35 PM, David Stevens <david.stevens at usu.edu> wrote:
>> R community,
>> Apologies if this has been answered. The concept I'm looking for is to
>> save() an object retrieved using get() for an object
>> that resulted from using assign. Something like
>> where assign(foo,obj) creates an object named foo with the contents of obj
>> assigned. For example, if
>> x <- data.frame(v1=c(1,2,3,4),v2=c('1','2','3','4'))
>> foo = 'my.x'
>> # (... then modify foo as needed)
>> # though this generates " in save(get(foo), file = paste(foo, ".rData", sep
>> = "")) :
>> object ‘get(foo)’ not found", whereas
>> at the command prompt yields the contents of my.x
>> There's a concept I'm missing here. Can anyone help?
>> David Stevens
>> David K Stevens, P.E., Ph.D.
>> Professor and Head, Environmental Engineering
>> Civil and Environmental Engineering
>> Utah Water Research Laboratory
>> 8200 Old Main Hill
>> Logan, UT 84322-8200
>> 435 797 3229 - voice
>> 435 797 1363 - fax
>> david.stevens at usu.edu
>> R-help at r-project.org mailing list
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> Gregory (Greg) L. Snow Ph.D.
> 538280 at gmail.com
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help