[R] use zoo package with multiple column data sets

e-letter inpost at gmail.com
Fri Jan 29 13:12:45 CET 2010


Readers,

I am trying to use the zoo package with an array of data:

file1:
hh:mm:ss	1
hh:mm:ss	2
hh:mm:ss	3
hh:mm:ss	4

file2:
hh:mm:ss	11	55
hh:mm:ss	22	66
hh:mm:ss	33	77
hh:mm:ss	44	88

I wanted to merge these data set so I tried the following commands:

library(chron)
library(zoo)
z1<-read.zoo("path/to/file1.csv",header=TRUE,sep=",",FUN=times)
z2<-read.zoo("path/to/file2.csv",header=TRUE,sep=",",FUN=times)
z3<-(na.approx(merge(z1,z2),time(z1)))
plot(z3$z1,z3$z2[3])

Warning message:
some methods for “zoo” objects do not work if the index entries in
‘order.by’ are not unique in: zoo(rval, ix)
> z3<-(na.approx(merge(z1,z2),time(z1)))
Error in merge.zoo(z1, z2) : series cannot be merged with non-unique
index entries in a series

I have read the document vignette 'zoo' but section 2.1 does not show
an example of the syntax for the command 'order.by'.

How to use the zoo package where the variable z2 contains many columns of data?

Yours,

rhelpatconference.jabber.org
r251



More information about the R-help mailing list