# NOT RUN {
r <- rast(ncols=10, nrows=10)
values(r) <- (0:99)/99
# classify the values into three groups
# all values >= 0 and <= 0.25 become 1, etc.
m <- c(0, 0.25, 1,
0.25, 0.5, 2,
0.5, 1, 3)
rclmat <- matrix(m, ncol=3, byrow=TRUE)
rc1 <- classify(r, rclmat, include.lowest=TRUE)
# equivalent to
rc2 <- classify(r, c(0, 0.25, 0.5, 1), include.lowest=TRUE)
# is becomes
x <- round(r*5)
unique(x)
m <- rbind(c(1,100), c(2,200))
m
rcx1 <- classify(x, m)
unique(rcx1)
rcx2 <- classify(x, m, othersNA=TRUE)
unique(rcx2)
# }
Run the code above in your browser using DataLab