[R] question for IF ELSE usage

From: ecoinfo <ecoinformatics_at_gmail.com>
Date: Wed 13 Jul 2005 - 00:22:38 EST


Hi R users,
 Maybe the question is too simple.
 In a IF ... ELSE ... statement "if(cond) cons.expr else alt.expr", IF and ELSE should be at the same line?
For example,
 if (x1==12)
{

y1 <- 5
}else
{

y1 <- 3
}
 is right, while
 if (x1==12)
{

y1 <- 5
}
else # Error: syntax error
{

y1 <- 3
}
 is wrong?
 Thanks

-- 
Xiaohua Dai
--------------------------------------------------------------------------------
Centre for Systems Research, Durban Institute of Technology
P.O.Box 953, Durban 4000, South Africa
Tel: +27-31-2042737(O) Fax: +27-31-2042736(O)
Mobile: +27-723682954

	[[alternative HTML version deleted]]

______________________________________________
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 Wed Jul 13 00:26:11 2005

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