【发布时间】:2017-05-15 14:41:56
【问题描述】:
我知道我可以使用 Rmarkdown 中的参数包含排除 r 代码块。 http://rmarkdown.rstudio.com/developer_parameterized_reports.html
但是,如何根据参数值排除或包含选项卡。 选项卡表示为:
## Header {.tabset}
### Tab 1
content Tab 1
### Tab 2
content Tab 2
##
我正在寻找类似的东西
## Header {.tabset}
### Tab 1
content Tab 1
ifelse(param == False) {
### Tab 2
content Tab 2
}
##
更新
我对 StatnMap 的回答有一些疑问。使用此代码,在第一个块中,R 块之后的 HTML 仍然显示为 R 块本身。我可以通过对 R 块使用单独的 eval = FALSE 来解决此问题,但我宁愿将自己限制为单个块中的单个参数。因此,只在 asis 块中设置eval = FALSE。
## HEADER {.tabset .tabset-pills}
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
``` {asis, echo = TRUE, eval = FALSE}
### TEST1
```{r echo=FALSE, warning=FALSE}
library(dplyr)
summary(cars)
```
You can also embed plots, for example:
```
### TEST2
```{r, pressure, echo=FALSE}
plot(pressure)
```
【问题讨论】:
标签: tabs include r-markdown parameterized chunks