Greg - I appreciate your taking the time to explain. This is very
helpful. My case was a bit unusual as I'm helping a colleague with code
to use on a regular but individual basis. I want them to name a data set
once at the top of the script and have that name propagate through
several objects
Seems to me you are creating your own troubles in your requirements. If the
analysis is the same from case to case, it makes more sense to use a single set
of object names within the analysis and change only the names of the input and
output files.
... and wrap it all up into a single function call that could even
have the user interactively supply the input data file names.
Cheers,
Bert
Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374
Data is not information. Information is not knowledge. And knowledge
is certainly not
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
save(get(foo),file=paste(foo,'rData',sep=''))
where assign(foo,obj) creates an object named foo with the
You can use the following command:
tmp - get(foo)
save(tmp,file=paste(foo,'.rData',sep=''))
Best,
Mike
2014-06-24 15:35 GMT-05:00 David Stevens david.stev...@usu.edu:
R community,
Apologies if this has been answered. The concept I'm looking for is to
save() an object retrieved using
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
I recommend to use saveRDS()/readRDS() instead. More convenient and
avoids the risk that load() has of overwriting existing variables with
the same name.
/Henrik
On Tue, Jun 24, 2014 at 1:45 PM, Greg Snow 538...@gmail.com wrote:
I think that you are looking for the `list` argument in `save`.
Thanks to all for the replies. I tried all three and they work great. I
was misinterpreting the list = parameter in save(...) and I get your
point about overwriting existing objects. I've heard about not using
assign/get before. Can anyone point me to why and what alternatives
there are?
Have you read An Introduction to R (ships with R) or other online R
tutorial (there are many good ones). Looks to me like you haven't
these are pretty basic R basics.
But maybe I misinterpret...
Cheers,
Bert
Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374
Data is not
The main reason to avoid assign/get is that there are better ways.
You can use a list or environment more directly without using
assign/get. Also the main reason to use assign/get is to work with
global variables which are frowned on in general programming (and
prone to hard to find bugs).
10 matches
Mail list logo