Re: [R] zoo and coredata() classes

From: <rory.winston_at_gmail.com>
Date: Tue, 03 Mar 2009 16:20:03 +0000


Thanks Gabor. Using the data.matrix() approach as outlined in the FAQ works for me.

Cheers
Rory

On Mar 3, 2009 4:00pm, Gabor Grothendieck <ggrothendieck_at_gmail.com> wrote:
> On Tue, Mar 3, 2009 at 10:37 AM, rory.winston@gmail.com> wrote:

> > Hi guys

> >

> > I have a reasonably basic question with zoo usage, but I havent been
> able

> > to find a satisfactory workaround yet.

> >

> > Heres a simple example of what I'm talking about (the following data
> frame

> > contains numeric columns that contains NAs):

> >

> >> head(ebs)

> > time src tstamp code bid ask

> > 1 2009-03-03 13:03:29.536 perf.Tib_listener 14980321164

> > EBS.REC.EURJPY=EBS.NaE 123.48 NA

> > 2 2009-03-03 13:03:29.786 perf.FilteringPublisher 14980565658
> EUR.JPY.SPOT

> > 123.48 123.51

> > 3 2009-03-03 13:03:29.786 perf.Tib_listener 14980566116

> > EBS.REC.EURJPY=EBS.NaE NA 123.51

> > 4 2009-03-03 13:03:30.036 perf.FilteringPublisher 14980824852
> EUR.JPY.SPOT

> > 123.49 123.50

> > 5 2009-03-03 13:03:30.051 perf.Tib_listener 14980835694

> > EBS.REC.EURJPY=EBS.NaE 123.49 123.50

> > 6 2009-03-03 13:03:30.520 perf.FilteringPublisher 14981302082
> EUR.JPY.SPOT

> > 123.49 123.51

> >

> >> class(ebs)

> > [1] "data.frame"

> >

> >> class(ebs$bid)

> > [1] "numeric"

> >

> >> any(is.na(ebs$bid))

> > [1] TRUE

> >

> >> class(ebs$ask)

> > [1] "numeric"

> >

> >> foo

> The first argument to zoo cannot be a data frame. From ?zoo

> Usage:

> zoo(x = NULL, order.by = index(x), frequency = NULL)

> Arguments:

> x: a numeric vector, matrix or a factor.

> Also see Question #4 in the zoo faq. From within R:

> library(zoo)

> vignette("zoo-faq")

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 03 Mar 2009 - 15:22:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 03 Mar 2009 - 15:30:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive