round a date in R to an arbitrary minute/hour level of precision
问题 I'm looking to group dates in R by an arbitrary level of precision. It's pretty straightforward to do this to the nearest hour or minute, using e.g. lubridate : library(lubridate) nearest_hour = floor_date(now(), 'hour') You can then group a list of such dates with e.g. a simple summarise ddply from plyr . What I'd like to do is round dates with arbitrary precision, e.g. to the nearest 15 minutes or every 3 hours: nearest_three_hours = floor_date(now(), '3 hours') There's a discussion of such