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?
For some reason to cut xts time of day using
x["T09:30/T11:00"]
is pretty slow, I use the method from R: Efficiently subsetting dataframe based on time of day and data.table time subset vs xts time subset to make a faster function with similar syntax:Test:
If your
xts
object is calledx
then something likey <- x["T09:30/T11:00"]
works for me to get a slice of the morning session, for example.