[R] ZOO objects: Creating, Plotting, Analyzing

Rich Shepard rshepard at appl-ecosys.com
Wed Mar 19 17:51:21 CET 2014


   I need to plot and analyze irregular time series. Having read the JSS
article on zoo (2005), ?zoo, ?plot.zoo, and the quickref vignette I'm still
not doing this correctly.

   My work flow is to read the *.csv file to create a dataframe, convert the
df to a matrix using as.matrix() (see s95.ec.txt attached), then cr⎈eate a
zoo object specifying 'sampdate' as the order.by index. The result is the
second attachment (s95.ec.z.txt) which does not appear correct to me.

   Of the several zoo methods involving NA values, none of the imputations
seem appropriate for my data as there is neither pattern or sufficiently
short gaps between observed values, so I chose 'na.omit.' Putting that in
the command, e.g., s95.ec.z <- zoo(s95.ec, order.by = 'sampdate', na.omit)
produced an error:

s95.ec.z <- zoo(s95.ec, order.by = 'sampdate', na.omit)
Error in frequency > 1 :
   comparison (6) is possible only for atomic and list types

   I suspect that the first hurdle I need to overcome is correctly creating a
zoo object from the matrix.

   All the data I analyze have irregular collection dates and I need to
become fluent with zoo objects so I can correctly analyze and plot the time
series of these data.

Rich
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: s95.ec.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20140319/ed3f51f6/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: s95.ec.z.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20140319/ed3f51f6/attachment-0001.txt>


More information about the R-help mailing list