I have converted a financial data frame to an xts
format in R. But, it drops the header for the date column.
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
The problem is when I am using the rCov
function from the highfrequency
package.
> rc <- rCov(rData = x, makeReturns = TRUE)
It gives me the following error:
Error in names(result) <- unique(as.Date(index(rData))) :
'names' attribute [670] must be the same length as the vector [669]
What I have understood is that the length of each column must be the same, however, the date column is one less due to the header problem, if I am correct.
Please, I would be grateful if someone could help me with this little issue?
The dput:
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, 8.68498, 8.68568, 8.68498, 8.68423, 1.69654, 1.69687, 1.69678, 1.69688), class = c("xts", "zoo"), index = structure(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"))
I am unable to reproduce the error. Try starting a fresh session of R and then try again.
giving: