R重组split.xts操作

发布于 2024-11-13 11:41:29 字数 1574 浏览 1 评论 0原文

我有一个 xts 对象(股票价格时间序列),它由多年的日内数据组成,即数据是一个连续的流,它将该期间每一天的日内数据拼接在一起。

我按分割对象(使用 split.xts(x, f="days)),因为我需要使用日内数据计算每天的各种专有操作。

现在我想重新- 将最终产品组合回与原始产品类似的 xts 对象,以便我可以将其导入另一个软件应用程序中进行研究。我尝试了使用 tapply 和 unlist 的各种操作,但没有成功

。物体XLE1_split由252个xts对象组成,我想重新组合这样一个对象。

> 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 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青萝楚歌 2024-11-20 11:41:29

我相信 do.call(rbind,XLE1_split) 应该做你想做的事。

I believe that do.call(rbind,XLE1_split) should do what you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文