[R] Is this a bug in quantmod::OpCl?

James Hirschorn james.hirschorn at hotmail.com
Wed Apr 6 04:17:58 CEST 2016


OpCl works on xts objects but not on quantmod.OHLC objects. Is this a bug?

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]]



More information about the R-help mailing list