The format argument to as.POSIXct
needs to have colons instead of hyphens to match the format of the time values. by
should be the interval between values in the sequence. length.out
can be used to specify the total number of values you want in the sequence, rather than specifying the interval with by
.
options(digits.secs=4)
time.seq = seq(from=as.POSIXct("14:03:55", format="%H:%M:%OS",tz="UTC"),
to=as.POSIXct("19:30:07", format="%H:%M:%OS", tz="UTC"), by=0.0315)
head(time.seq)
[1] "2016-01-21 14:03:55.0000 UTC" "2016-01-21 14:03:55.0315 UTC"
[3] "2016-01-21 14:03:55.0629 UTC" "2016-01-21 14:03:55.0945 UTC"
[5] "2016-01-21 14:03:55.1259 UTC" "2016-01-21 14:03:55.1575 UTC"
Note that since there's no date given, as.POSIXct
attaches today's date to the time values.