I don't understand why R gives me a warning about "Longer object length is not a multiple of shorter object length"
I have this object which is generated by doing an aggregate over an xts series giving the weekday median:
u <- aggregate(d, list(Ukedag = format(index(d),"%w")), median)
1 314.0
2 282.5
3 270.0
4 267.0
5 240.5
Then I try to apply this to my original xts series, which looks like this (only a lot longer)
head(d)
2009-01-02 116
2009-01-05 256
2009-01-06 286
Using:
coredata(d) <- coredat(d) - u[format(index(d),"%w")];
Which results in a warning.
The intent is to subtract the weekday mean. It appears to work despite the warning, but what should I worry about?
Revised solution: Attempt 2
apply.daily(d, function(x) coredata(x) - u[format(index(x), "%w")] )
I did indeed have a serious error. This doesn't give any warnings and I tested it by doing:
apply.daily(d, function(x) u[format(index(x), "%w")] )
Then checking some dates, and it appeared that is was in alignment with the calendar.