[R] if then else
Duncan Murdoch
murdoch at stats.uwo.ca
Sat Sep 30 15:26:09 CEST 2006
On 9/30/2006 6:29 AM, Uwe Ligges wrote:
>
> Jue.Wang2 at sanofi-aventis.com wrote:
>> What is the correct form to write statement meaning:
>>
>> if (a==1) {b=2; c=3}; else {b=0; c=0};
>
>
> if (a==1) {b=2; c=3} else {b=0; c=0};
That's valid, but is it "correct form"? The semicolon at the end is not
needed. I'd say it's a bad idea to use one, because it might give a
mistaken impression about the meaning of something like
a = 1
+ 2;
It's better to avoid semi-colons whenever possible, to make sure the C
parser in your brain throws an exception and lets the R parser take over.
Duncan Murdoch
More information about the R-help
mailing list