[R] Including time in a zoo

From: Horace Tso <Horace.Tso_at_pgn.com>
Date: Tue 10 Oct 2006 - 21:19:24 GMT

dear list,

I have these hourly price data over a 20 year period. Among other things, I want to plot them with time on the x-axis. The data is in a data frame,

> head(OWI.SE.all)

   Record_Number               Name Condition      Time_Period    Price
13            12 WECC-OWI SouthEast       All 1/1/2012 Hour: 1 41.21383
28            27 WECC-OWI SouthEast       All 1/1/2012 Hour: 2 38.38091
43            42 WECC-OWI SouthEast       All 1/1/2012 Hour: 3 39.97879
58            57 WECC-OWI SouthEast       All 1/1/2012 Hour: 4 40.14156
73            72 WECC-OWI SouthEast       All 1/1/2012 Hour: 5 38.21092
88            87 WECC-OWI SouthEast       All 1/1/2012 Hour: 6 40.09152

And the date-times are in a POSIX object dte1,

> class(dte1)

[1] "POSIXt" "POSIXlt"

When I tried to create a zoo with dte1 as the index, I got an error,

> zoo(OWI.SE.all, dte1)

Error in order(x, ..., na.last = na.last, decreasing = decreasing) :

        unimplemented type 'list' in 'orderVector1'

I guess that's saying the index of a zoo can't have a time component. Am I correct? If so, is there a way to include an hour component in a zoo object.

Second question:

If I just attach this dte1 to my data frame as a column named Date and try plotting it as,

> plot(OWI.SE.all$Date, OWI.SE.all$Price, type="l")

I got non-sensical result. How do I plot hourly data in general?

TIA. Horace W. Tso



R-help@stat.math.ethz.ch 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 Wed Oct 11 07:23:54 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 10 Oct 2006 - 23:30:08 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.