r - 选项卡中的多个块
问题描述
我希望在单个选项卡中包含示例 1 和示例 2,在另一个选项卡中包含示例 3。下面的代码在一个选项卡中显示所有内容。在我想要的输出中,sectionA 选项卡中的一些块和 sectionB 选项卡中的一些块。
---
title: "R Notebook"
output:
html_document:
df_print: paged
code_folding: show
theme: united
highlight: tango
toc: true
toc_float: true
toc_depth: 3 # upto three depths of headings (specified by #, ## and ###)
---
```{r, echo=FALSE}
library(rmarkdown) #used for syntax highlighting in this document
```
## Sections {.tabset}
### Section A
# Example1
```{r, eval=FALSE}
plot(cars)
```
<details>
<summary>Click for Output</summary>
```{r, echo=FALSE, eval=TRUE}
plot(cars)
```
</details>
### Section B
# Example2
```{r}
quantile(mtcars$mpg, probs = c(0.99))
```
## {-}
# Example3
```{r table}
knitr::kable(mtcars[1:5,, 1:5], caption = "A table caption")
``````
解决方案
如果我理解正确,您想要这些方面的东西吗?一旦你开始一个选项卡式的部分,你就不能随便扔掉子部分,但应该遵循特定的层次结构。如果您有一个选项卡部分 level ##
,则 level 下的所有内容都###
将成为选项卡。任何比这更深的东西都将成为所述选项卡中的标题。
## Sections {.tabset}
### Section A
#### Example1
```{r, eval=FALSE}
plot(cars)
```
<details>
<summary>Click for Output</summary>
```{r, echo=FALSE, eval=TRUE}
plot(cars)
```
</details>
#### Example2
```{r}
quantile(mtcars$mpg, probs = c(0.99))
```
### Section B
#### Example3
```{r table}
knitr::kable(mtcars[1:5,, 1:5], caption = "A table caption")
``````
推荐阅读
- php - 从搜索查询中获取图像
- java - 使用 Spring Boot RestController 进行 Junit 测试
- github - 从 c# 将文件上传到 github 的任何简单方法?
- java - 错误初始化 SpringBoot v.2.1.10.RELEASE app 构造函数参数 0
- verilog - Not 运算符在赋值中的意外结果
- xamarin - Webview OnProgressChanged 和进度条
- python - 迭代Python字典并构建新字典的正确方法
- python-3.x - 从桌面/文件夹拖到 GUI
- attributes - 整合 xarray 的属性
- r - 估计回归线的方程