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

Uwe Ligges ligges at statistik.uni-dortmund.de
Thu Jul 22 08:59:24 CEST 2004


Liaw, Andy wrote:

>>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...

He meant that .Rprofile is loaded before package graphics is attached, 
and therefore hsv() cannot be found.
Attaching the package in .Rprofile or setting a hook should be sufficient.

Uwe Ligges



> 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
>>
>>
> 
> 
> ______________________________________________
> 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