ztable 的 RMarkdown pdf_output |表 |表格
RMarkdown pdf_output of ztable | xtable | htmlTable
我使用 ztable、xtable 或 htmlTable 包成功生成了 tables,没有任何问题。但是,我想知道这些 table 是否可以输出为 pdf 文档。当我尝试编织 pdf_output 时,没有显示 table。相反,信息显示为多个字符串。我试过更改乳胶引擎(使用 ztable)和其他方法,但没有成功。
我看过这里:
http://www.mzan.com/article/29773068-rmarkdown-latex-table-output-difficulties.shtml
我也看过小插曲等
示例(RMarkdown):
---
output: pdf_document
---
```{r, message = F, results = 'asis'}
# will throw out Error: pandoc document conversion failed with error 43
library(ztable)
data(iris)
options(ztable.type="latex")
zt <- ztable(iris[1:5,], caption = "ztable")
zt <- addcgroup(zt,
cgroup = c("group 1", "group 2"),
n.cgroup = c(2,3))
print(zt)
```
```{r, message = F }
# since it's html, will produce text only
library(htmlTable)
data(mtcars)
colnames(mtcars) <- NULL
htmlTable(mtcars[1:5,], caption = "htmlTable",
cgroup = c("group 1", "group 2"),
n.cgroup = c(5,6))
```
添加 header-includes: \usepackage{colortbl}
解决了 ztable
的错误。我认为 htmlTable
没有 Latex 引擎。
完整代码:
---
output: pdf_document
header-includes: \usepackage{colortbl}
---
```{r, message = F, results = 'asis'}
library(ztable)
data(iris)
options(ztable.type="latex")
zt <- ztable(iris[1:5,], caption = "ztable")
zt <- addcgroup(zt,
cgroup = c("group 1", "group 2"),
n.cgroup = c(2,3))
print(zt)
```
```{r, message = F }
# since it's html, will produce text only
library(htmlTable)
data(mtcars)
colnames(mtcars) <- NULL
htmlTable(mtcars[1:5,], caption = "htmlTable",
cgroup = c("group 1", "group 2"),
n.cgroup = c(5,6))
```
我使用 ztable、xtable 或 htmlTable 包成功生成了 tables,没有任何问题。但是,我想知道这些 table 是否可以输出为 pdf 文档。当我尝试编织 pdf_output 时,没有显示 table。相反,信息显示为多个字符串。我试过更改乳胶引擎(使用 ztable)和其他方法,但没有成功。
我看过这里:
http://www.mzan.com/article/29773068-rmarkdown-latex-table-output-difficulties.shtml
我也看过小插曲等
示例(RMarkdown):
---
output: pdf_document
---
```{r, message = F, results = 'asis'}
# will throw out Error: pandoc document conversion failed with error 43
library(ztable)
data(iris)
options(ztable.type="latex")
zt <- ztable(iris[1:5,], caption = "ztable")
zt <- addcgroup(zt,
cgroup = c("group 1", "group 2"),
n.cgroup = c(2,3))
print(zt)
```
```{r, message = F }
# since it's html, will produce text only
library(htmlTable)
data(mtcars)
colnames(mtcars) <- NULL
htmlTable(mtcars[1:5,], caption = "htmlTable",
cgroup = c("group 1", "group 2"),
n.cgroup = c(5,6))
```
添加 header-includes: \usepackage{colortbl}
解决了 ztable
的错误。我认为 htmlTable
没有 Latex 引擎。
完整代码:
---
output: pdf_document
header-includes: \usepackage{colortbl}
---
```{r, message = F, results = 'asis'}
library(ztable)
data(iris)
options(ztable.type="latex")
zt <- ztable(iris[1:5,], caption = "ztable")
zt <- addcgroup(zt,
cgroup = c("group 1", "group 2"),
n.cgroup = c(2,3))
print(zt)
```
```{r, message = F }
# since it's html, will produce text only
library(htmlTable)
data(mtcars)
colnames(mtcars) <- NULL
htmlTable(mtcars[1:5,], caption = "htmlTable",
cgroup = c("group 1", "group 2"),
n.cgroup = c(5,6))
```