1

I'm writing a function which does some data pre-processing, and one of the things I'm doing is creating a regularly spaced xts object. All of the examples I've seen use seq.POSIXt in a way similar to this:

temp <- xts(, seq.POSIXt(from = start(data), to = end(data), by = 0.001)
data <- cbind(temp, data)
data <- data["T08:30:00.001/T15:00:00"]

Is there a way to specify the from/to directly as a time of day without specifying a date? I'm wasting a lot of time by cbinding to "temp" when temp usually begins at 0:00:00 and ends at 11:59:59, and then cutting the result to 8:30:00.001 to 15:00:00. I'd much prefer the temp to start at 8:30:00.001 and end at 15:00:00, if that's possible.

Joshua Ulrich
  • 173,410
  • 32
  • 338
  • 418
tmakino
  • 618
  • 1
  • 5
  • 20

1 Answers1

3

No there is not as the sequence is over POSIXt types and you cannot have a date + time type without an underlying date.

You can of course write yourself a helper function which just injects a given, or randomly chosen, date and then does the magic once a complete time object has been formed.

Note that xts too will need a correct POSIXt object.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725