[R] Function arguments and copying objects
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue May 10 20:56:05 CEST 2005
R-devel is the appropriate place for C programming questions: please DO
read the posting guide.
You need to check the NAMED flag and call duplicated as necessary.
There are many examples in src/main/*.c.
On Tue, 10 May 2005, Giovanni Petris wrote:
>
> 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 at 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 at 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
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list