I can live with that. Thanks Ista!
-- Stergios Marinopoulos ----- Original Message ----- From: Ista Zahn <istaz...@gmail.com> To: Stergios Marinopoulos <stergios_marinopou...@yahoo.com> Cc: R. Project Help <r-help@r-project.org> Sent: Wednesday, July 30, 2014 2:50 PM Subject: Re: [R] xtable problems with xts objects Hi Stergios, I think as.data.frame(x) solves both your problems. Best, Ista On Wed, Jul 30, 2014 at 5:22 PM, Stergios Marinopoulos <stergios_marinopou...@yahoo.com> wrote: > 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 > > ______________________________________________ > R-help@r-project.org mailing list > 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. ______________________________________________ R-help@r-project.org mailing list 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.