renderTable gives error with dates and times #129

wch opened this Issue Mar 20, 2013 · 4 comments


None yet

3 participants

wch commented Mar 20, 2013 edited by bborgesr

The root of the problem is with print.xtable:

dat <- data.frame(date=as.POSIXlt(today()), x=1:5)
dtable <- xtable(dat)
# 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)
# 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.

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

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):

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

And you can also use renderDataTable():

@yihui yihui added this to the 0.9.0 milestone Feb 26, 2014
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