[R] Is there any difference between <- and =
murdoch at stats.uwo.ca
Wed Mar 11 15:52:06 CET 2009
On 3/11/2009 10:18 AM, Sean Zhang wrote:
> Dear R-helpers:
> I have a question related to <- and =.
> I saw very experienced R programmers use = rather than <- quite
> However, I heard from others that do not use = but always stick to <- when
> assigning valuese.
> I personally like = because I was using Matabl, But, would like to receive
> expert opinion to avoid potential trouble.
Use <- for assignment, and = for function arguments. Then the
f( a = 3 )
f( a <- 3 )
is clear, and you won't be surprised that a gets changed in the second
case. If you use = for assignment, the two lines above will be written as
f( a = 3 )
f( ( a = 3 ) )
and it is very easy to miss the crucial difference between them.
> Many thanks in advance.
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> 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