Skip to content

Is this a bug in quantmod::OpCl?

1 message · Joshua Ulrich

#
On Fri, Apr 8, 2016 at 10:51 AM, James Hirschorn
<james.hirschorn at hotmail.com> wrote:
Using xts should be fine.  I'm not sure whether there's much
functionality in quantmod that depends on the quantmod.OHLC class.
The result of the above command only has 1 column, though the input
data has 5 columns.  So it's "OK" in the sense that it doesn't throw
an error, but the output is a bit surprising.
Looks like a different bug.  The 11x5 matrix is being converted to a
55-element vector, and that vector is used to attempt to create an xts
object with an 11-element index.
Yes, that's the default behavior of stats::lag, and zoo::lag.zoo
follows that convention for consistency.  xts::lag.xts breaks the
convention because we thought it was too surprising/confusing to most
users (even though it's documented in the *Note* section in
?stats::lag).

I recommend you use xts and the lag generic, and avoid using Lag() and
quantmod.OHLC objects.