I assume you have a list
of rasterLayer
s ( or perhaps a stack
). If you already have a stack
, skip step one, but I assume you have a list
not a matrix
which I have called mylistofrasters
...
#1 - Get all rasters in the list into a stack
mystack <- do.call( stack , mylistofrasters )
#2 - Take mean of each pixel in the stack returning a single raster that is the average
mean.stack <- calc( mystack , mean , na.rm = TRUE )