[R] ZOO: Learning to apply it to my data

Rich Shepard rshepard at appl-ecosys.com
Tue Sep 13 20:07:07 CEST 2011


   I have read ?zoo but am not sure how to relate the parameters (x,
order.by, frequency, and style) to my data.frame. The structure of the
data.frame is

'data.frame':	11169 obs. of  4 variables:
  $ stream  : Factor w/ 37 levels "Burns","CIL",..: 1 1 1 1 1 1 1 1 1 1 ...
  $ sampdate: Date, format: "1987-07-23" "1987-09-17" ...
  $ param   : Factor w/ 8 levels "As","Ca","Cl",..: 1 1 1 1 1 1 1 1 1 1 ...
  $ quant   : num  0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0 ...

   The numeric column ('x' in zoo, I believe) is associated with the unique
combination of param, sampdate, and stream in each row. For example:

tail(streamdata)
        stream   sampdate param   quant
11164 Winters 2010-06-30   SO4 120.000
11165 Winters 2010-06-30    Zn   0.010
11166 Winters 2011-06-06    As   0.005
11167 Winters 2011-06-06    Cl   5.000
11168 Winters 2011-06-06   SO4 150.000
11169 Winters 2011-06-06    Zn   0.010

   I'm in the early exploratory stage of understanding these data, but want
to produce time series plots and analyses by stream and param using zoo
objects since the sampdate varies by both stream and chemical.

   I assume that order.by, the index, is sampdate. The frequency option is
FALSE because these samples are not temporally regular. I've no idea what to
do with the style option, if anything.

   Most of the examples I see on using R (including in the lattice book I'm
now reading) have one or more numeric columns in the data.frame associated
with a single factor. I have a single numeric column associated with two
factors and a date.

   If there are other documents or books I should read to learn how to
effectively use the zoo package for my project (in addition to zoo.pdf that
lists the methods and is quite obtuse to me), please point me to them. I
would greatly appreciate any and all help in getting up to speed with zoo.

TIA,

Rich



More information about the R-help mailing list