[R] xtable problems with xts objects
Stergios Marinopoulos
stergios_marinopoulos at yahoo.com
Wed Jul 30 23:22:47 CEST 2014
Hi, I'm having trouble getting xtable to print a simple xts object. When the frequency is 1800 I get an error. However when frequency(x) is reported as 1 it works. I have included example below.
Another question is how can I have the time index printed in place of the row number?
Thanks for your help,
--
Stergios Marinopoulos
library(xts)
library(xtable)
# This does not work. The indices are 1800 seconds apart.
x = xts(x=rep(pi, 6), order.by=as.POSIXlt( "2014-01-01 06:30:00" ) + 1800 * 0:5 )
print(xtable(x))
print(frequency(x)) # [1] 0.0005555556
# This is the error message:
# Error in rep(NA, start(x)[2] - 1) : invalid 'times' argument
# It works when I make the indices only 1 second apart.
x = xts(rep(pi, 6), as.POSIXlt( "1970-01-01 00:00:00" ) + 0:5 )
print(xtable(x))
print(frequency(x)) # [1] 1
# Here is a daily data example that works.
library(quantmod)
AAPL = getSymbols("AAPL", auto.assign=FALSE, from="2014-01-01", to="2014-01-10")
print(xtable(AAPL), include.rownames=TRUE)
print(frequency(x)) # [1] 1
More information about the R-help
mailing list