I’m trying to create a data column that lists only the hour each observation took place from time data that’s formatted as HH:MM:SS in R.
I want to do this so I can group observations in my dataset by the hour they took place.
Example time vector: a <- c(22:00:03, 22:00:05, 22:00:07, 22:00:09)
Desired output: [1] 22 22 22 22
My dataset is very large so creating separate vectors with the observations based on hour feels time-consuming.
I’ve tried to explore the ‘lubridate’ function but I’m having trouble finding a solution.
Any help is appreciated!
2