编织到 PDF 时使用双垂直规则创建 rmarkdown table

Creating a rmarkdown table with a double vertical rule when knitting to PDF

以下代码在从 R Studio 编译时生成一个带有 table 的 PDF 文件。有没有办法在变量之间插入双竖线(规则)?这最好使用 pander 但我不限于此。

---
output: 
    pdf_document:
        fig_caption: yes
---

```{r}
pander::pander(cars[1:5,], 
               split.cell = 80, 
               split.table = Inf, 
               digits = 4, 
               caption = "Some Caption\label{tab:sometable}",
               justify = c('right', 'left'))
```


编辑

我已尝试按照以下答案中的建议使用 htmlTable。不幸的是,这不会创建有效的降价代码,因此 knitr 可以创建 PDF,例如

---
output: 
    pdf_document:
        fig_caption: yes
---

```{r}
library('htmlTable')
htmlTable(as.matrix(cars)[1:5, ], caption = 'Table 1: Some caption.',
          css.table = 'border-collapse: collapse; border-style: hidden; border-bottom: 1px;',
          css.cell = 'border-style: none double none none;')
```

产生:

+1 用于 htmlTable

library('htmlTable')
htmlTable(as.matrix(cars)[1:5, ], caption = 'Table 1: Some caption.',
          css.table = 'border-collapse: collapse; border-style: hidden; border-bottom: 1px;',
          css.cell = 'border-style: none double none none;')

您可能想试试 Max Gordon 的 htmlTable

他在小插图中的例子:

htmlTable(txtRound(mx, 1), 
          col.columns = c(rep("#E6E6F0", 4),
                          rep("none", ncol(mx) - 4)),
          align="rrrr|r",
          cgroup = cgroup,
          n.cgroup = n.cgroup,
          rgroup = c("First period", 
                     "Second period",
                     "Third period"),
          n.rgroup = rep(5, 3),
                    tfoot = txtMergeLines("&Delta;<sub>int</sub> correspnds to the change since start",
                                "&Delta;<sub>std</sub> corresponds to the change compared to national average"))

创建

对于 pdf 的 xtable 将是我显示 tables:

的首选
```{r results="asis",echo=FALSE,message=FALSE}
library(xtable)

print(xtable(as.matrix(cars)[1:5, ],align=c("rr||r"), caption="some caption"), include.rownames=FALSE)

```

产生这个输出:

有多种选项可用于修改您的 table: https://cran.r-project.org/web/packages/xtable/xtable.pdf