开发者

R xts object subseting xts object with multiple days of intraday data for certain hours

开发者 https://www.devze.com 2023-03-31 20:42 出处:网络
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 itdoe

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"  开发者_JS百科  "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 has time-of-day subsetting: xts tick data rolling subset

tdata['T10:00:00/T12:00:00'] should do.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号