I have the following data to import from CSV to an xts, as the date-price are inconsistent in the data seek to merge. For some dates there is no entry. When using merge
/merge.xts
there are a variety of errors below. What is best methodology?
Date 2y Date 10y Date BankRate
02/08/2016 0.21 02/08/2016 0.815 02/08/2016 0.5
01/08/2016 0.164 01/08/2016 0.73 01/08/2016 0.5
...
09/06/2000 6.145 12/06/2000 5.108 05/01/2000 5.5
08/06/2000 6.169 09/06/2000 5.118 04/01/2000 5.5
07/06/2000 6.122 08/06/2000 5.162 03/01/2000 5.5
- Using
as.xts(read.zoo(...))
gives error index has 2621 bad entries at data rows: 3 4 8... Using
grid <- read.csv("gridukyield.csv", header=T) grid$Date <- as.Date(grid$Date, "%d/%m/%Y") UK2y <- grid[,c("Date","X2y")] UK2y <- as.zoo(UK2y)
gives error charToDate(x) string not in a unambiguous format
Using
dates <- xts(Date = seq(as.Date("2000-01-01"), as.Date("2016-08-01"), by='1 day')) dates <- dates[isWeekday(dates)] group <- merge(dates, UK2y, by="Date", all = T )
gives error improper length of one or more arguments to merge.xts
What is best methodology?