【问题标题】:R Markdown (Rmd) hide a paragraph of general text based on conditionR Markdown (Rmd) 根据条件隐藏一段普通文本
【发布时间】:2015-07-15 11:37:57
【问题描述】:

我正在编写 Rmd 向下报告,我想根据 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"))
    }
```

不幸的是,这会在一个框中输出可选段落,加上与一般摘要段落完全不同的字体,并且感觉肯定有更好的方法来做到这一点

【问题讨论】:

    标签: r rstudio knitr


    【解决方案1】:

    如何在代码块头中使用results='asis'

    ```{r, echo=FALSE, results='asis'}
    if ( resultType1 ) {
      cat(c("lines of blurb","more lines of blurb"))
    }
    ```
    

    也可以用##等打印标题

    【讨论】:

      猜你喜欢
      • 2021-09-08
      • 2013-06-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多