Parseltongue Parseltongue - 2 months ago 13
R Question

Pander formats tables weirdly when using significance stars and pandoc

If I run a linear regression with significance stars, render it through pander, and "Knit PDF" such as this:

pander(lm(crimerate ~ conscripted + birthyr + indigenous + naturalized, data = data), add.significance.stars = T)


I occasionally get output where there is weird spacing issues between rows in the output table.

enter image description here

I've tried setting pander options to report fewer digits
panderOptions('digits', 2)
, but the problem persists.

Does anybody have any ideas?

Answer

I had the same problem. Something is wrong with the cell alignment, this error disappeared when i changed style to rmarkdown.

library(data.table)
dt <- data.table(Test = c("0 - 10 000"),
                 ALDT = "99.18 %")

First(space in table):

pandoc.table(dt, justify = c("left", "right"))
# From pandoc below
------------------
   Test     ALDT  
---------- -------
0 - 10 000 99.18 %
------------------

Second(good formatting):

pandoc.table(dt, style = "rmarkdown", justify = c("left", "right"))
# From pandoc below
| Test          |    ALDT |
|:--------------|--------:|
| 0 - 10 000    | 99.18 % |

The first try doesn't work, something is wrong with the formatting pandoc gives us. But if you specify the style as rmarkdown it seems like the formatting is as it should be.