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?<
You can use the align.time function in the xts package to handle the rounding, then format to return a string of "HH:MM":
align.time
format
R> library(xts) R> p <- as.POSIXct("2012-05-30 20:41:21", tz="UTC") R> a <- align.time(p, n=60*15) # n is in seconds R> format(a, "%H:%M") [1] "20:45"