Using zoo would allow you to retain the date/time portion. In ts you would
have to represent them as numbers; however, as you can easily switch
from zoo to ts you probably want to use zoo in the first instance:
library(zoo)
library(chron)
Lines <- "DateID HourID Metrics
20060920 0 1
20060920 1 2"
z <- read.zoo(textConnection(Lines), header = TRUE, format =
"%Y%m%d")
metrics <- aggregate(z[,2], chron(unclass(time(z))) + unclass(z[,1])/24, sum)
metrics
as.ts(metrics)
On 12/11/06, Harshal D Dedhia <harshal at yahoo-inc.com>
wrote:> I have hourly data for approximately 21 days in the following format
>
> DateID HourID Metrics
> 20060920 0 xxxxxx
> 20060920 1 xxxxxx
>
> The hour ids correspond to one hour windows starting 00:00 to 23:59.
>
> I have never dealt with TS data before. What is the best way to handle
> this data? TS objects or use the Zoo package?
>
> Thanks in advance.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>