[R] Saving objects in RData file in different name

K. Elo m@||||@t@ @end|ng |rom pp@|net@||
Sat Jul 28 14:36:57 CEST 2018


Hi!

Maybe not the most elegant solution, but a workaround is to have a
function:

> save2<-function(y, ...) { save(y,...)}
> save2(x1,x2,file="test.RData")

The point is to include the variables to be "renamed" as parameters (in
my example: y). The function will use the parameter variable names when
saving the file.

HTH,
Kimmo

2018-07-28, 17:04 +0530, Christofer Bogaso wrote:
> Hi,
> 
> Let say I have 2 objects as below
> 
> x1 = 1:3
> x2 = 5:4
> 
> Now I want to save both x1 and x2 in some RData file, however x1 will
> be
> saved with a different name e.g. y
> 
> I tried below
> 
> save(y = x1, x2, file = "file.RData")
> 
> However still they are saved in their original names i.e. x1 and x2,
> not y
> and y2.
> 
> Is there any possibility that I can achieve above without explicitly
> copying y = x1 before y is passed to save()
> 
> Thanks for any feedback.
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-gui
> de.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list