Skip to content

round Date object to 10 minutes intervals?

3 messages · Katharina May, Brian Ripley, kmay

#
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:

            

  
    
#
Dear Mr. Ripley,

your answer perfectly fits my needs, thank you very much.
(And yes, rounding 5 to even is what I wanted).


Prof Brian Ripley wrote
Prof Brian Ripley wrote
This really got me thinking and as a result increased my understanding of
maths & R ,
a big thanks to you  



--
View this message in context: http://r.789695.n4.nabble.com/round-Date-object-to-10-minutes-intervals-tp4185496p4185776.html
Sent from the R help mailing list archive at Nabble.com.