[R] Omitting NAs in aggregate.ts()

Waichler, Scott R Scott.Waichler at pnl.gov
Tue May 17 00:19:27 CEST 2005


I have a time series vector (not necessarily ts class) that has NAs in
it.
How can I omit the NAs when using aggregate.ts() to compute a function
on each window?  If there is at least one non-NA value in each window,
I'd like to proceed with evaluating the function; otherwise, I would
like NA returned.  I'm not wedded to aggregate.ts and don't need ts
class if there is another fast, vectorized way to handle this.  Here is
what I am trying to do, with the invalid na.rm thrown in:

as.vector(aggregate.ts(x, ndeltat=24, FUN=min, na.rm=F))

Thanks,
Scott Waichler
Pacific Northwest National Laboratory
scott.waichler at pnl.gov




More information about the R-help mailing list