[R] How can I assign an argument to transfer whether by ref or by value?

Adaikalavan Ramasamy ramasamy at cancer.org.uk
Sun Nov 6 18:48:27 CET 2005


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 +0000, 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?
> 
> Cheers,
> Xiaofan
> 
> ---
> Xiaofan Li
> Department of Applied Mathematics and Theoretical Physics
> University of Cambridge
> 
> ______________________________________________
> 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
> 
-- 
Adaikalavan Ramasamy                    ramasamy at cancer.org.uk
Centre for Statistics in Medicine       http://www.ihs.ox.ac.uk/csm/
Wolfson College Annexe                  Tel : 01865 284 408
Linton Road, Oxford OX2 6UD             Fax : 01865 284 424




More information about the R-help mailing list