[R] Truncating (rounding down) to nearest half hour.

APOCooter mikeedinger16 at gmail.com
Thu Jul 19 19:03:23 CEST 2012


I couldn't find anything in the chron or timeDate packages, and a good search
yielded rounding to the nearest half hour, which I don't want.

The data:

structure(list(Date = structure(c(1209625080, 1209641460, 1209652500, 
1209676800, 1209682860, 1209692100, 1209706980, 1209722580, 1209726300, 
1209739620, 1209762780, 1209765720, 1209770520, 1209791040, 1209812580, 
1209829920, 1209837180, 1209848160, 1209854640, 1209859440, 1209870780, 
1209887760, 1209901080, 1209921660, 1209929280, 1209945600, 1209957240, 
1209980280, 1210001760, 1210017000, 1210021140, 1210034820, 1210042800, 
1210048980, 1210061520, 1210074480, 1210081200, 1210089300, 1210095960, 
1210104120, 1210110900, 1210110900, 1210118400, 1210126980, 1210134180, 
1210142640, 1210156080, 1210164180, 1210176840, 1210183740), class =
c("POSIXct", 
"POSIXt"), tzone = ""), Score = c(80L, 11L, 81L, 152L, 130L, 
122L, 142L, 20L, 1L, 31L, 93L, 136L, 128L, 112L, 48L, 57L, 92L, 
108L, 100L, 107L, 81L, 37L, 47L, 70L, 114L, 125L, 99L, 46L, 108L, 
106L, 111L, 75L, 75L, 136L, 36L, 13L, 35L, 71L, 105L, 113L, 116L, 
116L, 94L, 130L, 102L, 19L, 1L, 33L, 78L, 89L)), .Names = c("Date", 
"Score"), row.names = c(NA, 50L), class = "data.frame")

I'm trying to round the time down to the nearest half hour, without losing
the date.  For example, 01/01/2009 1:29 would round to 01/01/2009 1:00,
while 01/01/2009 1:31 would round to 01/01/2009 1:30.

Any help is greately appreciated.

--
View this message in context: http://r.789695.n4.nabble.com/Truncating-rounding-down-to-nearest-half-hour-tp4637083.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list