# NOT RUN {
r <- rast(nrows=5, ncols=5)
values(r) <- -10:14
x <- ifel(r > 1, 1, r)
# same as
a <- classify(r, cbind(1, Inf, 1))
b <- app(r, fun=function(i) {i[i > 1] <- 1; i})
d <- clamp(r, -Inf, 1)
y <- ifel(r > 1, 1, ifel(r < -1, -1, r))
z <- ifel(r > -2 & r < 2, 100, 0)
k <- ifel(r > 0, r+10, ifel(r < 0, r-10, 3))
# }
Run the code above in your browser using DataLab