Is this what you are after:
> x <- c(1327211358, 1327221999, 1327527296, 1327555433, 1327701042,
+ 1327761389, 1327780993, 1327815670, 1327822964, 1327897497, 1327897527,
+ 1327937072, 1327938300, 1327957589, 1328044466, 1328127921, 1328157588,
+ 1328213951, 1328236836, 1328300276, 1328335936,
1328429102)>
> x <- as.POSIXct(x, origin = '1970-1-1')
> x
[1] "2012-01-22 05:49:18 EST" "2012-01-22 08:46:39 EST"
"2012-01-25
21:34:56 EST"
[4] "2012-01-26 05:23:53 EST" "2012-01-27 21:50:42 EST"
"2012-01-28
14:36:29 EST"
[7] "2012-01-28 20:03:13 EST" "2012-01-29 05:41:10 EST"
"2012-01-29
07:42:44 EST"
[10] "2012-01-30 04:24:57 EST" "2012-01-30 04:25:27 EST"
"2012-01-30
15:24:32 EST"
[13] "2012-01-30 15:45:00 EST" "2012-01-30 21:06:29 EST"
"2012-01-31
21:14:26 EST"
[16] "2012-02-01 20:25:21 EST" "2012-02-02 04:39:48 EST"
"2012-02-02
20:19:11 EST"
[19] "2012-02-03 02:40:36 EST" "2012-02-03 20:17:56 EST"
"2012-02-04
06:12:16 EST"
[22] "2012-02-05 08:05:02 EST"> table(format(x, "%H"))
02 04 05 06 07 08 14 15 20 21
1 3 3 1 1 2 1 2 4 4>
>
On Sun, Feb 5, 2012 at 4:54 AM, Hasan Diwan <hasan.diwan at gmail.com>
wrote:> I have a list of numbers corresponding to timestamps, a sample of which
follows:
> c(1327211358, 1327221999, 1327527296, 1327555433, 1327701042,
> 1327761389, 1327780993, 1327815670, 1327822964, 1327897497, 1327897527,
> 1327937072, 1327938300, 1327957589, 1328044466, 1328127921, 1328157588,
> 1328213951, 1328236836, 1328300276, 1328335936, 1328429102)
>
> I would like to group these into hours. In other words, something like:
> c( "2012-01-31 21:14:26 PST" "2012-02-01 20:25:21 PST"
> ?"2012-02-02 04:39:48 PST" "2012-02-02 20:19:11 PST"
> "2012-02-03 02:40:36 PST" "2012-02-03 20:17:56 PST"
> "2012-02-04 06:12:16 PST" "2012-02-05 08:05:02 PST")
> Hour ?Hits
> 21 ? ? ?1
> 20 ? ? ?3
> 4 ? ? ? ?1
> 2 ? ? ? ?1
> 6 ? ? ? ?1
> 8 ? ? ? ?1
>
> How would I do this without too much pain (from a CPU perspective)?
> This is a subset of a million entries and I would rather not go
> through these manually... So, any advice? Many thanks! -- H
> --
> Sent from my mobile device
> Envoyait de mon portable
>
> ______________________________________________
> 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.
--
Jim Holtman
Data Munger Guru
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.