OK. It looks like I just have several NA values at the start of my array:

> which (is.na(x_ema))
[1] 1 2 3 4 5 6 7 8 9

That make sense, because the moving average is not defined for those
positions. I'll just have to set those values to zero:

> x_ema = replace(x_ema, which(is.na(x_ema)), 0)
> which (is.na(x_ema))
integer(0)

The mean() call works now and I can get on with my work. I'll have to
remember to condition the data like this in the future.

Thanks for the help!

Reuben Bellika

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to