[R] time series with quality codes

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Thu Aug 16 10:50:47 CEST 2007

On Thu, 16 Aug 2007, Felix Andrews wrote:

> list(...),
> I am working with environmental time series (eg rainfall, stream flow)
> that have attached quality codes for each data point. The quality
> codes have just a few factor levels, like "good", "suspect", "poor",
> "imputed". I use the quality codes in plots and summaries. They are
> carried through when a time series is aggregated to a longer
> time-step, according to rules like "worst", "median" or "mode".
> I need to support time steps of anything from hours to years. I can
> assume the data are regular time series -- they might be irregular
> initially but could be 'regularized'. But I would want to plot
> irregular time series along with regular ones.
> So far I have been using a data frame with a POSIXct column, a numeric
> column and a factor column. However I would like to use zoo instead,
> because of its many utility functions and easy conversion to ts. Is
> there any prospect of zoo handling such numeric + factor data? Other
> suggestions on elegant ways to do it are also welcome.

There is some limited support for this in zoo. You can do
   z <- zoo(myfactor, myindex)
and work with it like a zoo series and then
will recover a factor. However, you cannot bind this to other series 
without losing the factor structure. At least not in a plain zoo series. 
But you can do
   df <- merge(z, Z, retclass = "data.frame")
where every column of the resulting data.frame is a univariate zoo series.

The final option would be to just have a data.frame as usual and put your 
data/index into one column. But then it's more difficult to leverage zoo's 

I would like to have more support for things like this, but currently this 
is what we have.


> Felix
> -- 
> Felix Andrews / °ÂʡΩ
> PhD candidate
> Integrated Catchment Assessment and Management Centre
> The Fenner School of Environment and Society
> The Australian National University (Building 48A), ACT 0200
> Beijing Bag, Locked Bag 40, Kingston ACT 2604
> http://www.neurofractal.org/felix/
> xmpp:foolish.android at gmail.com
> 3358 543D AAC6 22C2 D336  80D9 360B 72DD 3E4C F5D8
> ______________________________________________
> R-help at stat.math.ethz.ch 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