[R] Creating ZOO Matrix from Data Frame
    Rich Shepard 
    rshepard at appl-ecosys.com
       
    Mon Jan  2 22:13:04 CET 2012
    
    
  
On Mon, 2 Jan 2012, Gabor Grothendieck wrote:
> Assuming you need a separate column for each site see the read.zoo split=
> argument.  An example is here:
> http://r.789695.n4.nabble.com/building-time-series-zoo-its-from-a-data-frame-tp2240349p2240814.html
   I created a new data frame for a single stream and it has this structure:
str(burns.tds)
'data.frame':	2472 obs. of  3 variables:
  $ site    : Factor w/ 137 levels "BC-0.5","BC-1",..: 5 5 5 5 5 5 5 5 ...
  $ sampdate: Date, format: "1992-03-27" "1992-04-30" ...
  $ quant   : num  0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 8.08 ...
This is in 'long' form with the date as the second column:
head(burns.tds)
      site   sampdate quant
599  BC-3 1992-03-27   0.1
600  BC-3 1992-04-30   0.1
601  BC-3 1992-05-30   0.1
603  BC-3 1992-06-19   0.1
1214 BC-3 1992-07-20   0.1
1215 BC-3 1992-08-10   0.1
   I've read the read.zoo help and above URL and cannot get the syntax
correct. Emulating the example at the bottom of the referenced Web page
produces an error that I interpret as a need to exclude NAs. Adding na.omit
to the command still produces an error:
burns.tds.z <- read.zoo(burns.tds, split = 1, format = "%Y-%m-%d", na.omit)
Error in strptime(format(x, scientific = FALSE), tz = tz, format = format):
   invalid 'tz' value
   How do I resolve this invalid 'tz' value? Or, is there another problem but
this is the error presented to me?
Rich
    
    
More information about the R-help
mailing list