I have a vector of POSIXct values and I would like to round them to the nearest quarter hour. I don\'t care about the day. How do I convert the values to hours and minutes?<
Old question, but would like to note that the lubridate
package handles this easily now with floor_date
. To cut a vector of POSIXct objects to 15 minute intervals, use like this.
x <- lubridate::floor_date(x, "15 minutes")
EDIT: Noted by user @user3297928, use lubridate::round_date(x, "15 minutes")
for rounding to the nearest 15 minutes. The above floors it.