Skip to content
Prev 78616 / 398502 Next

Warning: condition has length > 1

nawaf b wrote:
?ifelse

myfunction <- function(x){ifelse(x >= 1, 0, x^2)}

 > myfunction(c(.3, 1, .7, 22))
[1] 0.09 0.00 0.49 0.00