gpt4 book ai didi

R Markdown (Rmd) 根据条件隐藏一段普通文本

转载 作者:行者123 更新时间:2023-12-05 00:21:34 25 4
gpt4 key购买 nike

我正在处理 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"))
}
```

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

最佳答案

使用 results='asis' 怎么样?在代码块头中。

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

也可以用##等打印标题。

关于R Markdown (Rmd) 根据条件隐藏一段普通文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31429345/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com