Skip to content
Prev 173561 / 398502 Next

Is there any difference between <- and =

I think most people find it odd at first if they have always used "=" but
quickly you get use to it and nothing could be more clear. It is explicit.
It is active and provides a direction, a value goes into an object. The
equal sign for assignment is ambiguous. 

As an example 

 x = 3

we only know that the value 3 is assigned to the object x because by
convention a number cannot be an object, if not it could be read as the
object "3" taking the value "x" The expression literally states that they
are equal, yet you cannot assume that all instances of 3 are equal to x, so
it is an inaccurate expression. On the other hand,

3 -> x  or 
x <- 3  

is very clear. It makes no changes to "3" only to "x"  I've been reading
"Data Manipulation with R" and find the author's use of "=" for assignment
disturbing. You quickly get use to -> and will find after a short time that
you prefer it.
Sean Zhang wrote: