Hi Robert,

Consider the following:

x <- c(1, 3, 5, 4, 6)
ifelse(x < 6 & x > 1, 1, 2)
[1] 2 1 1 1 2

HTH,
Jorge


On Fri, May 21, 2010 at 9:36 AM, Robert U <> 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
>
>
>
>
>
>
>        [[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.
>
>

        [[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.

Reply via email to