There is a seq.POSIXt
function which has the nice property that the by
argument will get parsed for "numeric interval" meaning of one of "sec", "min", "hour", "day", "DSTday", "week", "month", "quarter" or "year . Then, if you print the results with format(z, "%H%M", tz="GMT")
it can appear as desired:
format( seq.POSIXt(as.POSIXct(Sys.Date()), as.POSIXct(Sys.Date()+1), by = "5 min"),
"%H%M", tz="GMT") # hours (00-23) and min (00-59) and no space
[1] "0000" "0005" "0010" "0015" "0020" "0025" "0030" "0035" "0040" "0045" "0050"
[12] "0055" "0100" "0105" "0110" "0115" "0120" "0125" "0130" "0135" "0140" "0145"
[23] "0150" "0155" "0200" "0205" "0210" "0215" "0220" "0225" "0230" "0235" "0240"
[34] "0245" "0250" "0255" "0300" "0305" "0310" "0315" "0320" "0325" "0330" "0335"
[45] "0340" "0345" snipped the rest.
Unless you are within 360/48 degrees of Greenwich (or is it Paris) you need to put in the tz="GMT"
so that the offset for your timezone does not mess this up. Without that this produced a sequence starting at "1700" for me. You could assign the inner result to a name if you needed to keep it available in your workspace, but it would not be a character value but rather a POSIXct object (numeric mode with class defined methods for display and manipulation):
z <- seq.POSIXt(as.POSIXct(Sys.Date()), as.POSIXct(Sys.Date()+1), by = "5 min")
> z[1]
[1] "2014-09-09 17:00:00 PDT"