r <- rast(system.file("ex/logo.tif", package="terra"))
rr <- c(r/2, r, r*2)
qr <- quantile(rr)
qr
if (FALSE) {
# same but slower
qa <- app(rr, quantile)
}
#quantile by layer instead of by cell
qg <- global(r, quantile)
Run the code above in your browser using DataLab