powered by
Operators for replacing values using the standard comparison operators.
x >= y <- valuex > y <- valuex <= y="" <-="" value<="" p="">x < y <- valuex == y <- valuex != y <- value=>
x > y <- value
x <= y="" <-="" value<="" p="">
x < y <- value
x == y <- value
x != y <- value
first element of the operation.
second element of the operation.
replacement value.
x with values for which the comparisons evaluate to TRUE replaced with value.
x
value
Thanks to these operators :
x == y <- value is equivalent to x[x == y] <- value
x[x == y] <- value
x != y <- value is equivalent to x[x != y] <- value
x[x != y] <- value
x <= y <- value is equivalent to x[x <= y] <- value
x <= y <- value
x[x <= y] <- value
x >= y <- value is equivalent to x[x >= y] <- value
x >= y <- value
x[x >= y] <- value
x < y <- value is equivalent to x[x < y] <- value
x[x < y] <- value
x > y <- value is equivalent to x[x > y] <- value
x[x > y] <- value
`==`
# NOT RUN { ages <- c(130, 10, 1996, 21, 39, 74, -2, 0) ages == 1996 <- as.numeric(format(Sys.Date(), "%Y")) - 1986 ages ages > 100 <- NA ages ages <= 0 <- NA ages # }
Run the code above in your browser using DataLab