rounding time - time arithmetic

Hi,
I need to round my time stamps to the nearest hour. I read "Round, floor and ceiling methods for date-time objects" in Lubridate, but unfortunately a previous colleague has separated the dates from the time stamps. I have tried case_when() and mutate_at() but the rounded times do not show in the new mutated column.

I need times under the half-hour to round back to the last hour, and times past the half-hour to round to the next hour. And then there are the time stamps exactly at the hour that will stay the same.

I would love to learn how apply() or map() could help me - or what ever the correct function would be. Apologies for not supplying a reprex but I am on a secure server and can not copy.

Thanks for your help.
Jonelle

The current state of your time data is ambiguous... can you povide a reprex of your data so we can understand it ?

Please have a look at this guide, to see how to create one:

Are the time stamps character strings?

Hi technocrat, No, the times are numerical (formatted as hms as I had called lubridate). ie. 07:00:00

1 Like

Yes, I realise that the reprex is valuable. I have logged off the secure platform but will make one when I log on again.

Hi, I have pasted the date and time columns back together and resolved the issue.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.