Re: [R] if then else

From: Uwe Ligges <ligges_at_statistik.uni-dortmund.de>
Date: Sat 30 Sep 2006 - 13:35:02 GMT

Duncan Murdoch wrote:
> On 9/30/2006 6:29 AM, Uwe Ligges wrote:

>>
>> Jue.Wang2@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

Of course, Duncan is right, and shame on me for posting it in such a pedagogically bad way on R-help, but I could not resist to simply remove a single semicolon from the original question.

Thank you, Duncan, for pointing it out.

Uwe



R-help@stat.math.ethz.ch 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. Received on Sat Sep 30 23:39:37 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 30 Sep 2006 - 14:31:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.