[R] save intermediate result

Joerg van den Hoff j.van_den_hoff at fzd.de
Fri May 4 22:13:07 CEST 2007


On Fri, May 04, 2007 at 03:45:10PM -0400, Weiwei Shi wrote:
> hi,
> 
> is there a way to save a R object into workspace instead of into a
> file during a running of function?
> 

if I understand the question correctly you want the 'super-assignment'
operator `<<-' as in

-------------cut---------------
R> f <- function(x) y <<- 2*x
R> f(1)
R> y
[1] 2
R> f(10)
R> y
[1] 20
-------------cut---------------

i.e. y is assigned a value in the 'workspace'. be careful, though, with
this kind of assignment. why not return the object you are interested
in as a list component together with other results when the function
call finishes?



More information about the R-help mailing list