On Tue, Apr 5, 2016 at 9:17 PM, James Hirschorn <james.hirsch...@hotmail.com> wrote: > > OpCl works on xts objects but not on quantmod.OHLC objects. Is this a bug? > Thanks for the minimal, reproducible example.
Looks like a bug. There's no as.quantmod.OHLC.xts method, so the zoo method is dispatched. Calling Op() or Cl() on this zoo-based object results in a vector (since zoo will drop dimensions, like a matrix or data.frame), and you can't set column names on a vector. I'm not sure whether it makes more sense to check for dims in all the combination transformations (consisting of combined Op, Hi, Lo, Cl) or to create a as.quantmod.OHLC.xts method. Can you provide some details about your use case? > Example error: > > x.Date <- as.Date("2003-02-01") + c(1, 3, 7, 9, 14) - 1 > set.seed(1) > x <- zoo(matrix(runif(20, 0, 1), nrow=5, ncol=4), x.Date) > q <- as.quantmod.OHLC(x,c("Open","High","Low","Close")) > > # error > OpCl(q) > #> Error in `colnames<-`(`*tmp*`, value = "OpCl.q") : > #> attempt to set 'colnames' on an object with less than two dimensions > > # OK > OpCl(as.xts(q)) > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Joshua Ulrich | about.me/joshuaulrich FOSS Trading | www.fosstrading.com R/Finance 2016 | www.rinfinance.com ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.