You want the compute the sd for each cell in a RasterBrick.
Here is a self-contained, minimal reproducible example
library(raster)
b <- brick(system.file("external/rlogo.grd", package="raster"))
Solution
x <- calc(b, sd)
x
class : RasterLayer
dimensions : 77, 101, 7777 (nrow, ncol, ncell)
resolution : 1, 1 (x, y)
extent : 0, 101, 0, 77 (xmin, xmax, ymin, ymax)
crs : +proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs
source : memory
names : layer
values : 0, 38.5746 (min, max)
It seems that this does not work for you because you have a RasterLayer called sd
sd <- b
calc(b, sd)
#Error in (function (classes, fdef, mtable) :
# unable to find an inherited method for function ‘calc’ for signature ‘"RasterBrick", "RasterBrick"’
In that case you can be more explicit and use the functions namespace
(stats)
calc(b, stats::sd)
And then it works again as expected.