[Rd] small syntax suggestion
Davor Cubranic
cubranic at stat.ubc.ca
Mon Aug 23 19:06:06 CEST 2010
On 2010-08-23, at 6:15 AM, Barry Rowlingson wrote:
> On Sun, Aug 22, 2010 at 4:33 PM, ivo welch <ivo.welch at gmail.com> wrote:
>> I have found that my students often make the mistake of
>> mixing up comparisons and assignments with negative numbers:
>>
>> if (x<-3) do_something;
>
> If you tell your students not to use '<-' for assignment, then they
> can't make this mistake, because = for assignment has additional
> restrictions on it:
The students are trying to *compare* to a negative number, and trip on R's parsing of "<-". They could use '=' for assignment all they want (which I thought is being discouraged as a code style these days, BTW), and they'll still run into this problem.
Davor
More information about the R-devel
mailing list