[R] Grouping together a time variable

R. Michael Weylandt michael.weylandt at gmail.com
Thu Feb 9 19:27:28 CET 2012


Perhaps cut.POSIXt (which is a generic so you can just call cut)
depending on the unstated form of your time object.

Michael

On Thu, Feb 9, 2012 at 12:15 PM, Abraham Mathew <abmathewks at gmail.com> wrote:
> I have the following variable, time, which is a character variable and it's
> structured as follows.
>
>> head(as.character(dat$time), 30) [1] "00:00:01" "00:00:16" "00:00:24" "00:00:25" "00:00:25" "00:00:40" "00:01:50" "00:01:54" "00:02:33" "00:02:43" "00:03:22"
> [12] "00:03:31" "00:03:41" "00:03:42" "00:03:43" "00:04:04" "00:05:09"
> "00:05:17" "00:05:19" "00:05:21" "00:05:22" "00:05:22"
> [23] "00:05:28" "00:05:44" "00:05:54" "00:06:54" "00:06:54" "00:07:10"
> "00:08:15" "00:08:26"
>
>
> What I am trying to do is group the data into one hour increment. So
> 5:01-6:00am, 6:01-7:00am, 7:01-8:00a,
> and so forth.
>
> However, I'm not sure if there's a simple route to do this in R or how to
> do it.
> Can anyone point me in the right direction?
>
> --
> *Abraham Mathew
> Statistical Analyst
> www.amathew.com
> 720-648-0108
> @abmathewks*
>
>        [[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