Richard Richard - 2 months ago 13
R Question

Subset xts object by time of day

A simple question: I know how to subset time series in

xts
for years, months and days from the help:
x['2000-05/2001']
and so on.

But how can I subset my data by hours of the day? I would like to get all data between 07:00 am and 06:00 pm. I.e., I want to extract the data during business time - irrelevant of the day (I take care for weekends later on). Help has an example of the form:

.parseISO8601('T08:30/T15:00')


But this does not work in my case. Does anybody have a clue?

Answer

If your xts object is called x then something like y <- x["T09:30/T11:00"] works for me to get a slice of the morning session, for example.