[R] Only referenc copy when calling C routine?

Liaw, Andy andy_liaw at merck.com
Mon Apr 12 02:29:43 CEST 2004

I thought that description is rather clear.  If `x' is a vector of doubles,

result <- .C("myCfunc", x = x)

makes a copy of `x' to be passed to `myfunc'.  The copy in R is not touched.
When `myfunc' returns, another copy is made and placed into result[["x"]].

There's the `DUP' argument in .C/.Fortran that controls whether the copying
is done.  See ?.C for detail.


> Shin, Daehyok
> What happens when I pass an array to a dynamically linked C routine?
> Is only its reference copied when an array is passed and returned?
> Or, is its whole content copied?
> In R extension manual, I found the following description.
> But, I can't know exactly which is true.
> "There can be up to 65 further arguments giving R objects to 
> be passed to
> compiled code.
> Normally these are copied before being passed in, and copied 
> again to an R
> list object when
> the compiled code returns. If the arguments are given names, 
> these are used
> as names for
> the components in the returned list object (but not passed to 
> the compiled
> code)."
> Thanks in advance.
> Daehyok Shin
> ______________________________________________
> 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