Skip to content
Prev 280026 / 398506 Next

round Date object to 10 minutes intervals?

You haven't specified how you want 00:05 rounded (it is neither > nor 
< 5).  But here's one way

t2 <- strptime(timeStamp, format="%d.%m.%Y %H:%M")
t2$min <- round(t2$min, -1)
[1] "31.03.2011 09:30" "31.03.2011 09:40" "31.03.2011 10:00" "31.03.2011 10:10"
[5] "31.03.2011 10:30" "31.03.2011 10:40" "31.03.2011 10:50" "01.04.2011 00:00"

That will round 5 to even.  You may need to consider things like
t2$min <- 10*floor((t2$min + 5)/10)
t2$min <- 10*floor((t2$min + 4)/10)
On Mon, 12 Dec 2011, Katharina May wrote: