On Fri, Oct 16, 2009 at 2:01 PM, Reuben Bellika <rube...@gmail.com> wrote: > 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)
Nooooo! Your mean is now biased toward zero! see ?mean and read the part about na.rm. -Ista >> 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. > -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org ______________________________________________ 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.