Getting error on TRMM time series stacked image using raster calc function

Hi all,
I am getting an error on a raster brick of TRMM precipitation data while trying to execute Savitzky-Golay filter using a function from the signal package. I am attaching the code and the error it produces below.

library(signal)
library(raster)
library(rgdal)
fun1 <- function(x) {
+   v=as.vector(x)
+   z=substituteNA(v, type="mean")
+   trmm.ts2 = ts(z, start=c(2001,1), end=c(2017,12), frequency=12)
+   x=sgolayfilt(trmm.ts2, p=1, n=3, ts=30)
+ }
savgol.trmm <- calc(trmm, fun1)

Error in .calcTest(x[1:5], fun, na.rm, forcefun, forceapply) :
cannot use this function

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.