[R] Two Questions on R (call by reference and pre-compilation)
Duncan Murdoch
murdoch.duncan at gmail.com
Wed May 5 02:43:04 CEST 2010
On 04/05/2010 5:05 PM, Ruihong Huang wrote:
> Hi All,
>
> I have two questions on R. Could you please explain them to me? Thank you!
>
> 1) When call a function, R typically copys the values to formal
> arguments (call by value). This is very cost, if I would like to pass a
> huge data set to a function. Is there any situations that R doesn't copy
> the data, besides pass data in an environment object.
>
R doesn't copy data unless it needs to, for example if your function
modifies its copy. So don't worry about the cost, there usually isn't
much of one.
> 2) Does R pre-compile the object function to binary when running
> "optim"? I experienced the R "optim" is much slower than the MATLAB
> "fmincon" function. I don't know MATLAB has done any pre-compilation on
> the script for object function or not. But perhaps, we can increase R
> performance by some sort of pre-compilation during running time.
>
There's an experimental compiler, but I don't know if there's a
predicted release date for it. R is not an easy language to compile.
Duncan Murdoch
>
> Thanks in advance.
>
>
> Best Regards,
> Ruihong
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list