Calculating new group variable based on timestamps

Hi, I suggest first taking a look at the lubridate package to convert your strings into datetime objects. It's pretty easy. Then, if you can put your sample into reproducible example, called a reprex, it will be easier for everyone to weigh in.