[英]Processing Rmarkdown inside chunks
我想以某些參數為條件,將格式化的部分添加到針織降價報告中。
例如,
```{r conditional, eval=outliers, result="asis"}
# If outliers==TRUE, the following section is added to the report
print(
"# Conditional section
## Subsection
This is here because **outliers==TRUE**!")
```
當然,以上根本不起作用。 我如何修改它才能做到?
您已經很親密了。 您需要使用cat
而不是print
。 您還將需要更改提供字符串的方式。 您的部分標題不會在其前面帶有空白。
---
title: "Untitled"
output: html_document
---
```{r}
outliers <- TRUE
```
```{r conditional, eval=outliers, results="asis"}
# If outliers==TRUE, the following section is added to the report
cat(
"# Conditional section
## Subsection
This is here because **outliers==TRUE**!")
```
或者
---
title: "Untitled"
output: html_document
---
```{r}
outliers <- TRUE
```
```{r conditional, eval=outliers, results="asis"}
# If outliers==TRUE, the following section is added to the report
cat(
"# Conditional section ",
"## Subsection ",
"This is here because **outliers==TRUE**!",
sep = "\n")
```
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.