yal*_*nal 5 r r-markdown bookdown
我的 RMarkdown 文档有代码块,可以从一个块中生成多个图形或表格。例如,它遍历一堆变量以生成每个变量的汇总统计表。问题是当我尝试生成 HTML 文档时,这些图形/表格的编号经常是错误的;编译PDF时不会发生此问题。问题是从同一个块生成的所有表都将获得相同的表号。
下面是一个例子:
---
title: "Testing Section Numbers"
author: "Authors"
date: "January 2019"
output:
bookdown::gitbook:
number_sections: yes
editor_options:
chunk_output_type: console
---
# R Markdown
Text text text
```{r pressure1, echo=FALSE, fig.cap=c("This is my plot", "This is my other plot")}
plot(pressure)
plot(iris)
```
```{r pressure2, echo=FALSE}
library(knitr)
kable(pressure, caption = "My first table")
kable(pressure, caption = "My second table")
```
Run Code Online (Sandbox Code Playgroud)
这是由于knitr的一个错误造成的,我刚刚在Github 上的开发版本中修复了该错误。请尝试
remotes::install_github('yihui/knitr')
Run Code Online (Sandbox Code Playgroud)