R xts 对象对 xts 对象进行子集化,其中包含特定时间的多天日内数据 [英] R xts object subseting xts object with multiple days of intraday data for certain hours

查看:18
本文介绍了R xts 对象对 xts 对象进行子集化,其中包含特定时间的多天日内数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 xts 对象中执行与下面相同的操作,但对于具有多天日内数据的 xts 对象?下面的工作就像一个时钟,但只有一天的数据.如果我将 xts 从 22 日传递到 26 日,则不会.似乎不可能一次性完成多天 xts 中的日内数据子集化,而是需要首先每天拆分数据,然后使用此 xts 功能.这样对吗?

Is there a way in xts object to do the same as below but for xts object with multiple days of intraday data? The below works like a clock but for one day of data. If I pass xts from 22nd to 26th it does not. It seems like subseting intraday data in xts across multiple days is not possible to be done in one go but rather need to first split data per each day and then use this xts functionality. Is this correct?

indexTZ(tdata) = "GMT"
plotdata= tdata['20110822 10:00:00/20110822 12:00:00']

> plotdata= tdata['10:00:00/12:00:00'] works like swiss clock


> tail(plotdata)
                SYMBOL EX  PRICE              SIZE    COND CORR G127
2011-08-22 11:59:36 "BHP"  "N" "38370"            "185"   "1"  "0"  "0" 
2011-08-22 11:59:37 "BHP"  "N" "38380"            "314"   "1"  "0"  "0" 
2011-08-22 11:59:40 "BHP"  "N" "38390"            "675"   "1"  "0"  "0" 
2011-08-22 11:59:42 "BHP"  "N" "38390"            "119"   "1"  "0"  "0" 
2011-08-22 11:59:43 "BHP"  "N" "38390"            "359"   "1"  "0"  "0" 
2011-08-22 11:59:44 "BHP"  "N" "38400.7702920749" "42763" "1"  "0"  "0" 

 plotdata= tdata['10:00:00/12:00:00'] or 
 plotdata= tdata['20110822 10:00:00/20110826 12:00:00'] does not return expected xts 

tail(plotdata)
                SYMBOL EX  PRICE              SIZE   COND CORR G127
2011-08-26 15:59:53 "BHP"  "N" "38710"            "119"  "1"  "0"  "0" 
2011-08-26 15:59:55 "BHP"  "N" "38700"            "1004" "1"  "0"  "0" 
2011-08-26 15:59:56 "BHP"  "N" "38700.4838709677" "310"  "1"  "0"  "0" 
2011-08-26 15:59:57 "BHP"  "N" "38710"            "6"    "1"  "0"  "0" 
2011-08-26 15:59:58 "BHP"  "N" "38710"            "2"    "1"  "0"  "0" 
2011-08-26 15:59:59 "BHP"  "N" "38710"            "121"  "9"  "0"  "0" 

推荐答案

xts 有时间子集:xts 刻度数据滚动子集

tdata['T10:00:00/T12:00:00'] 应该可以.

这篇关于R xts 对象对 xts 对象进行子集化,其中包含特定时间的多天日内数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆