Skip to content
Prev 169980 / 398506 Next

ifelse()

It is checking the series of values of X and returning a series of 1  
and 0's;
    1 if it meets your condition (X>0) and
    0 if it doesn't.

What did you expect?

A more complex invocation might look like this:
 > ifelse( X > 0, 1:3, -1:-2)
[1]  1  2  3  1 -1 -2
Note the recycling of the elements of the yes and no arguments

Consider also:

 > (X>0)+0
[1] 1 1 1 1 0 0