[R] Function arguments and copying objects

From: Giovanni Petris <GPetris_at_uark.edu>
Date: Wed 11 May 2005 - 04:10:40 EST

I have a function that, via .Call, modifies its argument, so I first create a backup copy of the object I want to pass, make a copy of it, and pass the copy to the function. However, my function also modifies the backup copy. I guess this has to do with R not duplicating objects until they are modified. Where can I read more about that? And/or how can I solve my problem, i.e. save a copy of the argument?

Here is an example of what I mean:

> mod.back$m0 <- rnorm(2)
> mod.back

$m0
[1] -0.03431583 -1.66513535

...

> mod <- mod.back
> dlmLLsvd(ip,mod)
> mod.back

$m0
[1] 3.360737 3.266844

...

Thanks in advance,
Giovanni

-- 

 __________________________________________________
[                                                  ]
[ Giovanni Petris                 GPetris@uark.edu ]
[ Department of Mathematical Sciences              ]
[ University of Arkansas - Fayetteville, AR 72701  ]
[ Ph: (479) 575-6324, 575-8630 (fax)               ]
[ http://definetti.uark.edu/~gpetris/              ]
[__________________________________________________]

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Wed May 11 04:18:10 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:41 EST