[R] difference between <- and =

Levi Larkey larkey at mail.utexas.edu
Fri Aug 29 18:20:40 CEST 2003


Hi,

I'm somewhat new to R and I'm trying to figure out the difference 
between the operators <- and =.

I've noticed that <- cannot be used to bind arguments to values in 
function definitions and calls.  That is, f(x <- 2) sets x to 2 in the 
calling frame and then calls f(2) because the expression x <- 2 returns 
a value of 2, whereas f(x = 2) sets x = 2 in the evaluation frame and 
not in the calling frame.  From what I can tell, = is only different 
than <- in the context of function definitions and calls.

Is there any reason for using one operator over the other outside of 
function definitions and calls?  Can someone point me to a precise 
specification of what each operator does?  Any help would be appreciated!

Levi




More information about the R-help mailing list