I have a large data set that represents observations at a given time in 24 hour format. I would like to get a histogram of just how many observations happened at each time listed. The data is in this format (Just a snippet):
Time
20:14:42
20:14:43
21:03:04
22:14:32
22:14:41
.
.
.
Is this possible?
Hi @jchimento,
Yes, it is possible.
I assume you don't want to see observations per each timestamp to the second, correct? I understand that you'd like to aggregate to an hour level or something, is that right?
You could assign your time column an hms class (using lubridate package) and then extract an hour from it by using an hour() function (same package).
library(lubridate)
x <- "23:15:02"
[1] "23:15:02"
x <- hms(x)
[1] "23H 15M 2S"
x_hour <- hour(x)
[1] 23
Or you can just plot your values right away after class assignment without extracting the hour, but your results may be tad granular.
I'm sure there is a base R solution with Posi-something class, but I have no expertise in that domain.