Message-ID: <971536df1001290433p1408acd5v1259aa57dedef8ac@mail.gmail.com>
Date: 2010-01-29T12:33:20Z
From: Gabor Grothendieck
Subject: use zoo package with multiple column data sets
In-Reply-To: <298a6f61001290412o242a2b20tc51e6a9e3ff23236@mail.gmail.com>
See FAQ #1 of the zoo faq:
vignette("zoo-faq")
On Fri, Jan 29, 2010 at 7:12 AM, e-letter <inpost at gmail.com> wrote:
> 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