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.