Rapporter / pander

An R Pandoc Writer: Convert arbitrary R objects into markdown
http://rapporter.github.io/pander/
Open Software License 3.0
294 stars 66 forks source link

support for integer64 columns #318

Closed mcol closed 6 years ago

mcol commented 6 years ago

When I use dbGetQuery() to query a database table (with the RMariaDB/DBI packages), integer values are now returned as integer64. Printing them with pander produces the wrong output.

> trait.types
          type count
1     clinical    69
2       glycan    45
3   IgG glycan    77
4 immune cells   424
5        lipid   182

> sapply(trait.types, class)
       type       count 
"character" "integer64"

> pander(trait.types)
---------------------------
     type         count    
-------------- ------------
   clinical     3.409e-322 

    glycan      2.223e-322 

  IgG glycan    3.804e-322 

 immune cells   2.095e-321 

    lipid       8.992e-322 
---------------------------

If I convert the column to be just an integer, then pander behaves as expected;

> trait.types$count <- as.integer(trait.types$count)

> pander(trait.types)
----------------------
     type       count 
-------------- -------
   clinical      69   

    glycan       45   

  IgG glycan     77   

 immune cells    424  

    lipid        182  
----------------------
mcol commented 6 years ago

Reproducible example:

library(pander)
df <- data.frame(a=letters[1:5], b=bit64::as.integer64(1:5))
pander(df)
daroczig commented 6 years ago

Looks like sapply and format doesn't like int64:

> sapply(bit64::as.integer64(1:5), format)
[1] "4.940656e-324" "9.881313e-324" "1.482197e-323" "1.976263e-323"
[5] "2.470328e-323"
daroczig commented 6 years ago

Seems to be OK now, please check.