我已将财务数据框转换为xts
R 中的格式。但是,它删除了日期列的标题。
EURAUD EURCAD EURGBP EURHKD
2013-10-01 00:00:00 1.45070 1.39638 0.83539 10.48859
2013-10-01 00:01:00 1.45058 1.39647 0.83539 10.48938
2013-10-01 00:02:00 1.45043 1.39636 0.83536 10.48825
问题是当我使用包中的rCov
功能时highfrequency
。
> rc <- rCov(rData = x, makeReturns = TRUE)
它给了我以下错误:
Error in names(result) <- unique(as.Date(index(rData))) :
'names' attribute [670] must be the same length as the vector [669]
我的理解是每列的长度必须相同,但是,如果我是正确的,由于标题问题,日期列会少一个。
请,如果有人能帮助我解决这个小问题,我将不胜感激?
输出:
structure(c(1.4507, 1.45058, 1.45043, 1.45035, 1.39638, 1.39647, 1.39636, 1.39641, 0.83539, 0.83539, 0.83536, 0.83538, 10.48859, 10.48938, 10.48825, 10.48868, 297.028, 297.028, 297.028, 297.028, 133.026, 133.071, 133.029, 133.003,1.62955,1.62925,1.62899,1.62898,43.82374,43.82374,43.82374,43.82374,43.82374,83.82374,8.68498,8.68568,8.68568,8.68568,8.68498,8.68498结构(c(1380571200、1380571260、1380571320、1380571380),tzone =“”,tclass = c(“POSIXct”,“POSIXt”)),.Dim = c(4L,10L),.Dimnames = list(NULL,c ("EURAUD"、"EURCAD"、"EURGBP"、"EURHKD"、"EURHUF"、"EURJPY"、"EURNZD"、"EURRUB"、"EURSEK"、"EURSGD"))