Example: if (abs(-1-1) <= 3 & abs(1+1) <= 3) {print(1)} else {print(2)}
----------------Contact Details:------------------------------------------------------- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) ---------------------------------------------------------------------------------------------- On Fri, May 21, 2010 at 4:39 PM, Sarah Goslee <sarah.gos...@gmail.com>wrote: > You need parentheses enclosing the entire if() statement: > > if(something & somethingelse) { > do this > } > > Sarah > > On Fri, May 21, 2010 at 9:36 AM, Robert U <tacsun...@yahoo.fr> wrote: > > Dear > > R-users, > > > > > > > > I've been trying to write a script but i encounter much problems with > basic > > functions.. That is, i try to write a simple IF ELSE statement, with 2 > > requirements for the IF : > > > > > > > > if (abs(x + Dataset$LAT[1]) <= 3) and (abs(y + Dataset$LONG[1]) <= 3) {z > > <- 1} else {z <-0} > > > > > > > > This does not work. So far i succeeded with one of tthe conditions : > > > > > > > > if (abs(x + Dataset$LAT[1]) <= 3) {z <- 1} else {z <-0} > >> this work, so i tried to had the second condition with "and" or > > "&" or even "& &&" as writen in operators > > r-help but none of my trials works, it retrun "unexpected symbol > > "{" ... > > > > > > > > any tip ? > > > > > > > > > > > > with regards > > > > > > > > > > > -- > Sarah Goslee > http://www.functionaldiversity.org > > ______________________________________________ > R-help@r-project.org 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. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org 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.