title: Round hour in timestamp (POSIXct) to the nearest multiple of a certain value in R
body: <p>I have a date/time value (POSIXct) where I want to round the "hour" value to a multiple of three (00:00, 03:00, 6:00, 9:00, 12:00...).</p>
  
  <p>So far I've extracted the hour as an integer, rounded it accordingly and inserted it back into a POSIXct format. Is there a quicker, more elegant way? This is my code so far:</p>
  
  <pre><code>timestamp &lt;- as.POSIXct("2015-10-14 14:00")
  timestamp.h &lt;- as.numeric(format(timestamp, "%H")) + as.numeric(format(timestamp, "%M"))/60
  timestamp.h.up &lt;- ceiling(timestamp.h/3)*3
  timestamp.up &lt;- as.POSIXct(paste(format(timestamp, "%Y-%m-%d")," ",timestamp.h.up,":00", sep=""))
  </code></pre>