Hi, I am not sure what is going on. I have previously smoothed my time series using a simple moving average using the code
precipSMA40.ts <- SMA(precip.ts, n = 40).
This code was running yesterday, and I was able to produce nice smoothed plots. However, I restarted R this morning, and when I re-run the code I receive the error:
"Error in SMA(precip.ts, n = 40) : could not find function "SMA". I am very confused why this function worked yesterday but not today. Does anyone have any advice? TIA
It seems this function SMA() is defined in a package, so before running this code you need to run library("packageName").
If it was working yesterday, I guess it's because you had loaded the package. It's possible it was the package {TTR}, which does have a function called SMA(). There are also a number of packages that have a function sma() in lowercase.