[R] saving results under specified file name

Frank E Harrell Jr f.harrell at vanderbilt.edu
Sun Sep 23 16:11:31 CEST 2007


Nitin Jain wrote:
> Hello,
> 
> I would like to save the results in a specified file name.  Here is a test example:
>  
> 
> aa <- function(xx, newname) {
>  yy <- xx^2
>     rdName <- file.path(paste(newname, ".RData", sep = ""))
>     assign(eval(newname), yy)
> save(newname, file=rdName) ## FIXME
> }
> 
> 
> aa(3, "test")
> 
> load("test.RData")
> ls() 
> 
> I would like to see test (which should store 9) rather than newname (which stores "test")
> 
> Please let me know how to do this.
> 
> Thanks.
> -Nitin

FYI see also the Save and Load functions in the Hmisc package. -Frank

> 
> 
> 
>       _________________________________________________________________________________
> stings, and more!
> http://tv.yahoo.com/collections/3658
> 
> ______________________________________________
> 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.
> 


-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University



More information about the R-help mailing list