将表格自动放入 Rmarkdown 的选项卡中
Putting tables automatically in tabs in Rmarkdown
我想自动将 for()
循环生成的表格放在不同的选项卡中。我使用了
下面的代码
但它不能正常用于表格。它创建选项卡但不显示其中的表格。有人可以更正我的代码吗?
---
output: html_document
---
# title 1 {.tabset}
There should be one table in each tab.
```{r echo=FALSE, warning=FALSE, results='asis'}
for(Species in levels(iris$Species)){
cat('\n##', Species, '\n')
p <- iris[iris$Species == Species,]
knitr::kable(p)
cat('\n')
}
```
您必须 print
您的表在 for
循环中:
---
output: html_document
---
# title 1 {.tabset}
There should be one table in each tab.
```{r echo=FALSE, warning=FALSE, results='asis'}
for(Species in levels(iris$Species)){
cat('\n##', Species, '\n')
p <- iris[iris$Species == Species,]
print(knitr::kable(p))
cat('\n')
}
```
我想自动将 for()
循环生成的表格放在不同的选项卡中。我使用了
但它不能正常用于表格。它创建选项卡但不显示其中的表格。有人可以更正我的代码吗?
---
output: html_document
---
# title 1 {.tabset}
There should be one table in each tab.
```{r echo=FALSE, warning=FALSE, results='asis'}
for(Species in levels(iris$Species)){
cat('\n##', Species, '\n')
p <- iris[iris$Species == Species,]
knitr::kable(p)
cat('\n')
}
```
您必须 print
您的表在 for
循环中:
---
output: html_document
---
# title 1 {.tabset}
There should be one table in each tab.
```{r echo=FALSE, warning=FALSE, results='asis'}
for(Species in levels(iris$Species)){
cat('\n##', Species, '\n')
p <- iris[iris$Species == Species,]
print(knitr::kable(p))
cat('\n')
}
```