По существу, более простая версия ответа larsoevlisen, так как я думаю, что вы можете делать все с lubridate (но трудно сказать без образца ваших данных):
library(tidyverse)
library(lubridate)
#create imaginary data set for this answer
#skip this step if you already have your data
df <- tibble(yourtimestamp = c("2019-06-04 11:20", "2019-06-04 11:25", "2019-06-04 12:00"))
#convert your timestamp vector to POSIX
df$yourtimestamp <- ymd_hm(df$yourtimestamp)
#the function you use here depends on what order the parts of your time stamp are,
#so for example if your character timestamp is US style: month, day, year
#such as
#06/20/2019 11:20 then use mdy_hm() instead
#or if it was UK style 20/06/2019 11:20 then use dmy_hm() etc
#or if it contains seconds such as 06/20/2019 11:20:47 use mdy_hms()
#get hour
df$just_the_hour <- hour(df$yourtimestamp)
#group by hour and summarise
by_hour <- group_by(df, just_the_hour)
s <- summarise(by_hour, num_events = n())
s
Выход:
# A tibble: 2 x 2
just_the_hour num_events
<int> <int>
1 11 2
2 12 1