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 obtain a xts object which has the same length of Cl(SPY) and the same dates... or it should be so.
If you input
merge(Cl(SPY), temp)
you will see that, although Cl(SPY) and temp have the same index date, they are not aligned, the code produces doubles and a lot of NAs.
How may I merge them in a correct way?