# NOT RUN {
r <- rast(ncol=9, nrow=9)
values(r) <- 1:ncell(r)
s <- c(r, r, r, r, r, r)
s <- s * 1:6
start <- end <- rast(r)
start[] <- 1:3
end[] <- 4:6
index <- c(start, end)
rapp(s, index, fun="mean")
# }
Run the code above in your browser using DataLab