renderTable gives error with dates and times #129

Closed
wch opened this Issue Mar 20, 2013 · 4 comments

Projects

None yet

3 participants

Contributor
wch commented Mar 20, 2013 edited by bborgesr

The root of the problem is with print.xtable:

library(xtable)
dat <- data.frame(date=as.POSIXlt(today()), x=1:5)
dtable <- xtable(dat)
print(dtable)
# Error in Math.POSIXt(x + ifelse(x == 0, 1, 0)) : 
#   'abs' not defined for "POSIXt" objects


dat <- data.frame(date=Sys.Date(), x=1:5)
dtable <- xtable(dat)
print(dtable)
# Error in Math.Date(x + ifelse(x == 0, 1, 0)) : 
#   abs not defined for Date objects

A workaround is to convert these columns to characters.
http://stackoverflow.com/questions/8652674/r-xtable-and-dates

jeffwong commented Sep 1, 2013

I have seen this problem too, is there a more official solution?

jeffwong commented Jan 3, 2014

Wanting to check in on this to see if there is a more official solution. It is pretty inconvenient to have to manipulate dates as characters

Member
yihui commented Jan 11, 2014

I guess we need a better maintained package for tables :) xtable has been making really slow progress in terms of fixing bugs and introducing new features...

This is something I'm personally interested in, but I have not decided how far I want to go. My first attempt was knitr::kable(), which may be developed into a separate package some day. You can see if this works (not an official solution):

runApp(list(
  ui = basicPage(
    tableOutput('foo')
  ),
  server = function(input, output, session) {
    output$foo <- function() {
      paste(knitr::kable(
        iris, format = 'html', output = FALSE,
        table.attr="class='data table table-bordered table-condensed'"),
        sep = '\n')
    }
  }
))

And you can also use renderDataTable(): http://rstudio.github.io/shiny/tutorial/#datatables

@yihui yihui added this to the 0.9.0 milestone Feb 26, 2014
Member
yihui commented Feb 26, 2014

Issue closed because it is a bug of xtable instead of shiny.

@yihui yihui closed this Feb 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment