Adding column to zoo object

断了今生、忘了曾经 提交于 2019-12-06 05:39:11

The problem is that z in the question is not a zoo object.

Either of these will create a zoo object with z as the first column and df$X as the second:

read.zoo(data.frame(rownames(z), Return = z, X = df$X), FUN = as.yearmon)

merge(Return = zoo(z, as.yearmon(rownames(z))), X = df$X)

giving:

               Return  X
Jan 1986           NA 11
Feb 1986  0.003082153 12
Mar 1986  0.003053556 13
Apr 1986  0.001660598 14
May 1986 -0.005117494 15
Jun 1986 -0.001453005 16
Jul 1986 -0.001716753 17
Aug 1986 -0.003354528 18
Sep 1986  0.000189813 19
Oct 1986  0.003498305 20
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!