[R] Na.omit on matrix, does the matrix have to have a limited size
Petr PIKAL
petr.pikal at precheza.cz
Fri Jan 22 15:19:10 CET 2010
Hi
I am not at all an expert on this issue but one option could be rollapply
from zoo package
rollapply(data, 5, mean, na.rm=T)
and other function embed
rowMeans(embed(x,5), na.rm=T)
But I believe there are other options.
Regards
Petr
r-help-bounces at r-project.org napsal dne 22.01.2010 15:01:14:
>
> Okay I had a look now at my matrix with clearer head than yesterday and
you
> are right, some columns have their own missing values that you don't
find in
> the other columns, I checked it yesterday many times because that was my
> guess as well but didn't see anything I don't understand why, sorry! So
I
> converted this matrix to a time serie now. The thing is that I want to
> calculate the moving average at t on a width x (so I would take the
values
> from t to (t - x + 1) but in the case I have Na's I want it to remain a
> moving average of width x excluding the Na value and taking the value at
t -
> x instead. Any guess on how I could do this? I am using runmean for the
> moment
> --
> View this message in context:
http://n4.nabble.com/Na-omit-on-matrix-does-the-
> matrix-have-to-have-a-limited-size-tp1068000p1100054.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list