I have a xts object (stock price time series) that is comprised of intraday data for multiple years i.e. the data is a continuous stream that stitches together intraday data for each day in the period.
I split the object by day (using split.xts(x, f开发者_开发问答="days)) as I need to compute various proprietary operations on a per day basis using the intraday data.
Now I want to re-combine the end product back to an xts object similar to that of the original so that I can import it into another software application for study. I have tried various operations using tapply and unlist without success. Appreciate the guidance.
Below is a snippet of the object XLE1_split which is composed of 252 xts objects. I want to recombine such an object.
> str(XLE1_split)
List of 252
$ :An ‘xts’ object from 2010-05-28 09:31:00 to 2010-05-28 16:00:00 containing:
Data: num [1:390, 1:8] 54 54 53.9 53.8 53.8 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:8] "XLE.Open" "XLE.High" "XLE.Low" "XLE.Close" ...
Indexed by objects of class: [POSIXct,POSIXt] TZ:
xts Attributes:
NULL
> head(XLE1_split)
[[1]]
XLE.Open XLE.High XLE.Low XLE.Close XLE.Volume XLE.WAP XLE.hasGaps XLE.Count
2010-05-28 09:31:00 53.95 53.97 53.89 53.97 664 53.935 0 237
2010-05-28 09:32:00 53.97 54.01 53.88 53.89 478 53.955 0 213
2010-05-28 09:33:00 53.90 53.92 53.79 53.82 350 53.854 0 217
2010-05-28 09:34:00 53.81 53.82 53.74 53.81 314 53.782 0 172
2010-05-28 09:35:00 53.82 53.83 53.69 53.69 502 53.762 0 198
2010-05-28 09:36:00 53.69 53.72 53.55 53.56 1366 53.601 0 817
2010-05-28 09:37:00 53.56 53.60 53.51 53.52 1724 53.562 0 742
2010-05-28 09:38:00 53.52 53.52 53.42 53.46 909 53.468 0 509
I believe that do.call(rbind,XLE1_split)
should do what you want.
精彩评论