Error: could not find the function "SMA"

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

I have looked at the R documentation page and am getting the error: page does not exist.

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.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.