r <- raster(nrow=18, ncol=36)
r[] <- runif(ncell(r)) * 10
# works for large files
cellStats(r, 'mean')
# same, but does not work for very large files
cellStats(r, mean)
# not quite the same
cellStats(r, 'sd')
cellStats(r, sd)
Run the code above in your browser using DataCamp Workspace