在 R Markdown 中向 Kable Table 添加标题
Adding a caption to a Kable Table in R Markdown
我正在使用 RMarkdown 写一些大学作业
我使用下面的代码创建了一个 table,需要将其导出到 Microsoft Word
谁能告诉我如何在 table 中添加描述数据的标签,或者之后我是否必须在 MS Word 中这样做
---
title: "Data"
author: "foo"
date: "2 July 2016"
output:
word_document:
bibliography: bibliography.bib
---
kable(table(Rawdata$Var1, Rawdata$Var2))
使用 kable
中的 caption
参数。
如果您需要更多选项来格式化 Word 输出中的表格,我建议您下载 Gmisc
包并使用 Gmisc::docx_document
格式。请记住,它将文件保存为 HTML 文件,可以作为 Word 文档打开并保留格式。
例如:
---
title: "Data"
author: "foo"
date: "2 July 2016"
output: Gmisc::docx_document
---
```{r}
knitr::kable(head(mtcars[, 1:3]),
caption = "This is the table caption")
```
我正在使用 RMarkdown 写一些大学作业 我使用下面的代码创建了一个 table,需要将其导出到 Microsoft Word
谁能告诉我如何在 table 中添加描述数据的标签,或者之后我是否必须在 MS Word 中这样做
---
title: "Data"
author: "foo"
date: "2 July 2016"
output:
word_document:
bibliography: bibliography.bib
---
kable(table(Rawdata$Var1, Rawdata$Var2))
使用 kable
中的 caption
参数。
如果您需要更多选项来格式化 Word 输出中的表格,我建议您下载 Gmisc
包并使用 Gmisc::docx_document
格式。请记住,它将文件保存为 HTML 文件,可以作为 Word 文档打开并保留格式。
例如:
---
title: "Data"
author: "foo"
date: "2 July 2016"
output: Gmisc::docx_document
---
```{r}
knitr::kable(head(mtcars[, 1:3]),
caption = "This is the table caption")
```