[R-SIG-Finance] Xts, Zoo Error: "number of items to replace not multiple of replacement length"
Wob Wu
wobwu22 at yahoo.de
Tue Mar 9 15:12:09 CET 2010
Hello,
I am trying to construct a continous price series of future contracts. This is all working well apart from one bit in my code. After spending hours of debugging I still can't find the source of the problem. So any help is highly appreciated!!!
Ok, so basically I am trying to replace the log returns on specific days. This works for nearly all contracts that I am converting, apart from a
few. And I really can't see what the difference between it is as the
code is exactly the same.
So the specific code is:
returnNorm[expiryDates,] <- returnRoll[expiryDates,];
This however fails with the error:
"Error in NextMethod(.Generic) : number of items to replace is not a multiple of replacement length"
where
class(returnNorm) and class(returnRoll) is "xts" "zoo"
class(expiryDates) is "Date"
and
dim(returnRoll[expiryDates,])
[1] 242 1
> dim(returnNorm[expiryDates,])
[1] 242 1
The data basically looks like this:
returnNorm[expiryDates,]
1.Close
1990-01-23 -0.04304175
1990-02-21 -0.02048786
1990-03-21 0.03466198
1990-04-23 0.06052630
1990-05-23 0.02568539
...
returnRoll[expiryDates,]
1.Close
1990-01-23 -0.007839561
1990-02-21 -0.018232046
1990-03-21 0.009564634
1990-04-23 0.013196285
1990-05-23 -0.042100119
...
expiryDates
[1] "1990-01-23" "1990-02-21" "1990-03-21" "1990-04-23" "1990-05-23" ...
______________________________
fügt über einen herausragenden Schutz gegen Massenmails.
http://mail.yahoo.com
More information about the R-SIG-Finance
mailing list