[R] if..else.. need help

Huntsinger, Reid reid_huntsinger at merck.com
Fri Mar 25 19:35:12 CET 2005


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 at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of msck9 at mizzou.edu
Sent: Friday, March 25, 2005 1:24 PM
To: Jeff D. Hamann
Cc: r-help at 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 at 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




More information about the R-help mailing list