Hello guys,
I am wondering the default way of transferring arguments in R. Is it by
value or by ref in default case, or could that be changed explicitly?
Cheers,
Xiaofan
---
Xiaofan Li
Department of Applied Mathematics and Theoretical Physics
University of Cambridge
Xiaofan Li wrote:
> Hello guys,
>
> I am wondering the default way of transferring arguments in R. Is it by
> value or by ref in default case, or could that be changed explicitly?
R passes by value. It's worth reading the language definition manual to
find out about the subtleties (e.g. lazy ev
I do not understand what your question is. Can you clarify with an
example or analogies to other programming language.
my.fun <- function(x, y=1){ x^y }
my.fun(5)# returns 5
my.fun(5, 2) # returns 25
my.fun(y=2, x=5) # returns 25
Regards, Adai
On Sun, 2005-11-06 at 03:28 +
i think this question was already answered but just to elaborate,
pass by value means that a copy of the argument is passed to the
function so if the argument is changed in the function its not changed
in the caller. Pass by reference means its changed in the caller too.
R passes by value although
Adai,
Duncan posted a reply to Xiaofan's query, indicating that R is generally
based upon pass by value.
The difference being that within R, either explicit values or explicit
copies of objects are passed as function arguments, as opposed to
passing a memory location reference to the original val