set.seed(0)
r <- rast(nrows=10, ncols=10, nlyrs=3)
values(r) <- runif(ncell(r) * nlyr(r))
x <- mean(r)
# note how this returns one layer
x <- sum(c(r, r[[2]]), 5)
# and this returns three layers
y <- sum(r, r[[2]], 5)
max(r)
max(r, 0.5)
y <- stdev(r)
# not the same as
yy <- app(r, sd)
z <- stdev(r, r*2)
x <- mean(r, filename=paste0(tempfile(), ".tif"))
Run the code above in your browser using DataLab