使用重要星和 pandoc 时,Pander 会奇怪地格式化表格 [英] Pander formats tables weirdly when using significance stars and pandoc

查看:31
本文介绍了使用重要星和 pandoc 时,Pander 会奇怪地格式化表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我运行带有重要星的线性回归,请通过 pander 和Knit PDF"进行渲染,例如:pander(lm(crimerate ~ 征兵 +birthyr + 土著 + 归化,数据 = 数据),add.significance.stars = T)

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.

我尝试设置 pander 选项以报告更少的数字 panderOptions('digits', 2),但问题仍然存在.

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

有人有什么想法吗?

推荐答案

我遇到了同样的问题.单元格对齐有问题,当我将样式更改为 rmarkdown 时,此错误消失了.

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 %
------------------

第二(格式良好):

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

第一次尝试不起作用,pandoc 给我们的格式有问题.但是,如果您将样式指定为 rmarkdown,则格式似乎应该如此.

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.

这篇关于使用重要星和 pandoc 时,Pander 会奇怪地格式化表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆