问题描述
一个简单的问题:我知道如何从帮助中将 xts
中的时间序列子集化为年、月和日:x['2000-05/2001']
等等.
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.
但是我如何按一天中的小时数来划分我的数据?我想在 07:00 am 和 06:00 pm 之间获取所有数据.即,我想在工作时间提取数据 - 与当天无关(稍后我会照顾周末).帮助有一个表单示例:
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?
推荐答案
如果你的 xts
对象被称为 x
那么类似于 y <- x[例如,T09:30/T11:00"]
对我有用,可以从早上的会议中分一杯羹.
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.
这篇关于按一天中的时间子集 xts 对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!