[R] Ragged time series data

Gabor Grothendieck ggrothendieck at gmail.com
Sat Oct 4 02:44:52 CEST 2008


Check out the zoo package and its three vignettes and
?aggregate.zoo in particular.

Also have a look at the article on dates and times in R News 4/1
and note the chron class which, in fact, accepts inputs in the
very form you have.

On Fri, Oct 3, 2008 at 7:39 PM, Joe Kaser <jmkaser at gmail.com> wrote:
> Hi and thanks in advance,
>
> I am fairly new with R so I hope this problem isn't too amateur.
>
> I have a vector of count data which correspond to vectors of date (%m/%d/%Y)
> and time of day (%H:%M:%S).
> I am trying to compute various statistics (e.g. daily max) by lumping the
> data together by day.   I have been able to utilize tapply() and group the
> counts together, but with the method I use I end up losing the corresponding
> time of day information.
>
> This is what I have done so far
>
> data=*vector of integers
> *hours= *"character" vector of times %H:%M:S% *
> days= *"character" vector of dates %m/%d/%Y
> *
> hr.days=paste(days,hours)
> hr.dayslt=as.POSIXlt(strptime(hr.days, format="%m/%d/%Y %H:%M:%S"))
>
> tapply(data,hr.dayslt$yday,max)
>
> This works to give me the counts I want corresponding to a Julain day, but
> it does not tell me which hour corresponds to each daily maximum.  Is
> tapply() the wrong route?
>
> Joe
> *
>
>
> *
>
>        [[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.
>



More information about the R-help mailing list