[R] Including time in a zoo

Gabor Grothendieck ggrothendieck at gmail.com
Wed Oct 11 01:20:07 CEST 2006


Its saying you are trying to pass a list to zoo (a data frame is a list);
however, from ?zoo we see zoo takes a first argument of:
"a numeric vector, matrix or a factor".

On 10/10/06, Horace Tso <Horace.Tso at pgn.com> wrote:
> 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 at 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.
>



More information about the R-help mailing list