RE: [R] if..else.. need help

From: Huntsinger, Reid <reid_huntsinger_at_merck.com>
Date: Sat 26 Mar 2005 - 05:35:12 EST


Well, if you type that at a command prompt, the expression is complete after the end of the "if" so you have an "else {}" which is orphaned. I think people usually use this style

if() {

} else {

}

or something similar to prevent this.

Reid Huntsinger

-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of msck9@mizzou.edu Sent: Friday, March 25, 2005 1:24 PM
To: Jeff D. Hamann
Cc: r-help@stat.math.ethz.ch
Subject: [R] if..else.. need help

Dear all,
 I don't know why the following doesn't work. if(cls$size[1]>cls$size[2])
 {cls1<-tempforce[cls$cluster==1];cls2<-tempforce[cls$cluster==2]} else {cls1<-tempforce[cls$cluster==2];cls2<-tempforce[cls$cluster==1]}

Error: syntax error

What is the problem here?

thanks.
Ming



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

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 Received on Sat Mar 26 05:39:20 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:56 EST