没有正确处理管道内部的pander mardown表

Gil*_*les 2 r pandoc knitr r-markdown pander

我使用pander R包生成markdown表,这些表包含一些列标题中的管道(例如:P> | t |).看起来(除非我遗漏了一些东西)由于柱分隔符和"真实"管道之间的混淆,它们既没有被pandoc也没有被Rmarkdown正确处理.

考虑以下Rmd示例:

```{r  message = FALSE}
library(pander)
panderOptions("table.style" , "rmarkdown")
panderOptions("table.split.table" , Inf) # avoid to split the tables

data(iris)
mod <- lm(Sepal.Length ~ Species, data = iris)
```

```{r results='asis'}
pandoc.table(summary(mod)$coefficients[,-4])
```

```{r results='asis'}
pandoc.table(summary(mod)$coefficients)
```
Run Code Online (Sandbox Code Playgroud)

pander生成的最后一个表看起来像这样(注意最后一列名称中的管道):

|                  &nbsp; |  Estimate  |  Std. Error  |  t value  |  Pr(>|t|)  |
|------------------------:|:----------:|:------------:|:---------:|:----------:|
|         **(Intercept)** |   5.006    |    0.0728    |   68.76   | 1.134e-113 |
|   **Speciesversicolor** |    0.93    |    0.103     |   9.033   |  8.77e-16  |
|    **Speciesvirginica** |   1.582    |    0.103     |   15.37   | 2.215e-32  |
Run Code Online (Sandbox Code Playgroud)

如果我将其编织为html(通过Rstudio按钮使用Rmarkdown生成HTML,如果我没有错),则最后一个表不会显示为表格,而是显示为HTML输出中的纯文本.
如果我使用knitr生成的md并使用pandoc将其转换为html,则输出为表,但最后一列名称变为"Pr(>".

没有最后一列的第一个表格正确显示.

Joh*_*ane 5

您可以使用反斜杠(\|)来逃避管道.