[R] if statement

AAsk AA2e72E at lycos.co.uk
Wed Mar 7 20:51:06 CET 2012


> x <- -1:4
> x<0 # returns TRUE (1) or FALSE (0)
[1]  TRUE FALSE FALSE FALSE FALSE FALSE
> x+as.numeric(x<0)
[1] 0 0 1 2 3 4



More information about the R-help mailing list