#Create a time vector to act as x

time<-sort(sample(97:297, nlayers(ndvi2000crop1)))

#locally-weighted polynomial regression of ndvi ~ time

t.lowess <- function(x,...) { if (is.na(x[1])) {NA} else {lowess(x,y,...)$y } }

f.pred <- calc(ndvi2000crop1, t.lowess)

When I calculate the function on image, an error appeared something like this "Error in .calcTest(x[1:5], fun, na.rm, forcefun, forceapply): cannot use this function". Can you tell me where this error comes from in this part?

Thank you