[R] add more data to a data file, problem with .Rprofile

Liaw, Andy andy_liaw at merck.com
Thu Jul 22 01:59:51 CEST 2004


> From: Francisco J Molina
> 
> Hi,
> 
> Is there a way to incorporate an R object x to a file already 
> containing R objects?
> It seems that 'save' is not capable to do this. If I save x 
> to a file containing
> previously saved data, then I will lose this data.

See if the following helps:

> x <- 2
> save(x, file="x.rda")
> rm(x)
> attach("x.rda")
> assign("y", 3, pos=2)
> ls(2)
[1] "x" "y"
> save(list=ls(2), file="x.rda")
> detach(2)
> x
Error: Object "x" not found
> y
Error: Object "y" not found
> attach("x.rda")
> x
[1] 2
> y
[1] 3
> ls(2)
[1] "x" "y"

 
> I use the funcion hsv in .Rprofile but it is recognized. 
> Couriously, if I source .Rprofile
> when R is already running I do not get any error message. 

Not sure what you mean...

Andy
 
> Thank you.
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>




More information about the R-help mailing list