如何防止 kable 格式化 table 之后的文本?
How to I keep kable from formatting text that follows the table?
我对 knitr 比较陌生。我正在尝试创建一个包含小 table 的文档。例如,考虑这个 rmd 文档:
---
title: "Kable Test"
author: "Dave"
date: "January 8, 2016"
output: html_document
---
This R Markdown document is for testing kable output when kable is given a data.frame with only one row.
```{r}
library(knitr)
df = data.frame(x=1,y=100,z=1000)
kable(df)
```
This text is after the table.
当我编写此文档时,文本 "This text is after the table." 的格式就好像它在 table 中一样。
我发现如果我在 kable(df) 和纯文本之间包含一个空块,则纯文本格式正确。
```{r}
kable(df)
```
```{r}
```
Same table followed by an empty chunk.
在这种情况下,"Same table ..." 的格式正确。
是否有我应该使用的 kable 参数以避免插入空块?
谢谢,
戴夫
在块末尾和新段落之间添加一个额外的换行符(空行):
---
title: "Kable Test"
author: "Dave"
date: "January 8, 2016"
output: html_document
---
This R Markdown document is for testing kable output when kable is given a data.frame with only one row.
```{r}
library(knitr)
df = data.frame(x=1,y=100,z=1000)
kable(df)
```
This text is after the table.
或使用 pander::pander
,它会自动执行此操作(通过始终在 table 之后添加一个额外的 line-break 来避免这种混淆)以及一些额外的糖分:
---
title: "Kable Test"
author: "Dave"
date: "January 8, 2016"
output: html_document
---
This R Markdown document is for testing kable output when kable is given a data.frame with only one row.
```{r}
library(knitr)
df = data.frame(x=1,y=100,z=1000)
pander::pander(df)
```
This text is after the table.
我对 knitr 比较陌生。我正在尝试创建一个包含小 table 的文档。例如,考虑这个 rmd 文档:
---
title: "Kable Test"
author: "Dave"
date: "January 8, 2016"
output: html_document
---
This R Markdown document is for testing kable output when kable is given a data.frame with only one row.
```{r}
library(knitr)
df = data.frame(x=1,y=100,z=1000)
kable(df)
```
This text is after the table.
当我编写此文档时,文本 "This text is after the table." 的格式就好像它在 table 中一样。
我发现如果我在 kable(df) 和纯文本之间包含一个空块,则纯文本格式正确。
```{r}
kable(df)
```
```{r}
```
Same table followed by an empty chunk.
在这种情况下,"Same table ..." 的格式正确。
是否有我应该使用的 kable 参数以避免插入空块?
谢谢, 戴夫
在块末尾和新段落之间添加一个额外的换行符(空行):
---
title: "Kable Test"
author: "Dave"
date: "January 8, 2016"
output: html_document
---
This R Markdown document is for testing kable output when kable is given a data.frame with only one row.
```{r}
library(knitr)
df = data.frame(x=1,y=100,z=1000)
kable(df)
```
This text is after the table.
或使用 pander::pander
,它会自动执行此操作(通过始终在 table 之后添加一个额外的 line-break 来避免这种混淆)以及一些额外的糖分:
---
title: "Kable Test"
author: "Dave"
date: "January 8, 2016"
output: html_document
---
This R Markdown document is for testing kable output when kable is given a data.frame with only one row.
```{r}
library(knitr)
df = data.frame(x=1,y=100,z=1000)
pander::pander(df)
```
This text is after the table.