Wacek Kusnierczyk wrote:
> Petter Hedberg wrote:
>
>> I´m a PhD student at the University of Warsaw, and have started using R.
>> In many books they specify to use <- instead of = when assigning
>> values, and this is also mentioned in older posts on the R website.
>>
>> However, it seams to me that some update has occured, becuase I
>> continously get the same result wether I use <- or =.
>>
>> I would be extremely helpful for any answer to this.
>> = seams more intuitive, so I assumed that an update had been made due
>> to popular demand and that was why I get the same output wether I use
>> <- or =.
>>
>>
>>
>
> czesc,
>
> <- and = are not exactly equivalent. while in many situations you may
> use = instead of <-, in some you can't:
>
> x <- 1
> x = 1
> # same thing
>
> foo = function(a) ...
>
> foo(x <- 2)
> # assign to x, and pass it to foo as the argument a
>
> foo(x = 2)
> # pass 2 to foo as the argument x
>
... but this is also legal if you really hate <- :
foo({x = 2})
# assign to x, pass to foo as a
vQ
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.