please try the following code:
library(quantmod) getSymbols('SPY', from = '1950-01-01') SPY <- to.monthly(SPY) temp <- xts(Cl(SPY), index(SPY))
You will get an xts object that has the same Cl(SPY) length and the same dates ... or it should be .
If you enter
merge(Cl(SPY), temp)
You will see that although Cl(SPY) and temp have the same index date, they are not aligned, the code doubles and many NA s.
How can I combine them correctly?
source share