[R] IF-ELSE question
Sarah Goslee
sarah.goslee at gmail.com
Fri May 21 15:39:08 CEST 2010
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 <tacsunday at 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
More information about the R-help
mailing list