Thanks to Cory Fletcher for reporting this issue via email.
There's a bug in WMA() when an xts object is passed in for x that begins with NA values (with default wts=1:n parameter). The return value will be a vector rather than an xts object as it should be, because of the call to x <- na.omit(x). This means that x and ma now have different lengths, and the final call to reclass(ma,x) fails to produce an xts object.
Minimal, reproducible example
x <- xts(x = c(NA,1:3), order.by = Sys.Date()+1:4)
wma <- WMA(x, 2)
str(wma) # vector, but should be xts
Thanks to Cory Fletcher for reporting this issue via email.
There's a bug in
WMA()
when an xts object is passed in forx
that begins with NA values (with defaultwts=1:n
parameter). The return value will be a vector rather than an xts object as it should be, because of the call tox <- na.omit(x)
. This means thatx
andma
now have different lengths, and the final call toreclass(ma,x)
fails to produce an xts object.Minimal, reproducible example