r <- raster(ncol=10, nrow=5)
r[] <- 1:ncell(r) * 2
getValues(r)
r[1]
r[1:10]
r[3:8] <- NA
r[1:10]
#equivalent to
getValues(r, format='matrix')
r[[1,1]]
r[[1:2,1:2]]
#first column
r[[,1]]
# first row
r[[1,]]
r[[]]
s <- stack(r,sqrt(r))
s[1:3]
Run the code above in your browser using DataLab