R Markdown(Rmd) 根据条件隐藏一段通用文本
R Markdown (Rmd) hide a paragraph of general text based on condition
我正在处理 Rmd down 报告,根据 R 变量,我想决定是否包含一个段落
例如
##Abstract
paragraph Blurb
If result type is 1 then
another paragraph of blurb
我找不到任何简单的方法来执行此操作。我试过使用代码块。
例如
```{r echo=FALSE}
if ( resultType1 ) {
cat(c("lines of blurb","more lines of blurb"))
}
```
不幸的是,这会在一个方框中输出可选段落,并使用与一般摘要段落完全不同的字体,并且感觉肯定有更好的方法来做到这一点
在代码块 header 中使用 results='asis'
怎么样?
```{r, echo=FALSE, results='asis'}
if ( resultType1 ) {
cat(c("lines of blurb","more lines of blurb"))
}
```
也可以用##等打印标题
我正在处理 Rmd down 报告,根据 R 变量,我想决定是否包含一个段落
例如
##Abstract
paragraph Blurb
If result type is 1 then
another paragraph of blurb
我找不到任何简单的方法来执行此操作。我试过使用代码块。
例如
```{r echo=FALSE}
if ( resultType1 ) {
cat(c("lines of blurb","more lines of blurb"))
}
```
不幸的是,这会在一个方框中输出可选段落,并使用与一般摘要段落完全不同的字体,并且感觉肯定有更好的方法来做到这一点
在代码块 header 中使用 results='asis'
怎么样?
```{r, echo=FALSE, results='asis'}
if ( resultType1 ) {
cat(c("lines of blurb","more lines of blurb"))
}
```
也可以用##等打印标题