Extract only text from Rmd documents

白昼怎懂夜的黑 提交于 2019-12-01 18:36:51

You can knit document without evaluating and including code.

Here's an example of dummy document foo.Rmd:

# Header 1

foo

## Header 2

bar

## Header 22

foobar

```{r}
1
```

text text text

```{r}
print(2)
```

We can knit this document using knitr::knit("foo.Rmd"), but in this case code chunks will be included in text. To deal with this we need to set knitr options:

library(knitr)
opts_chunk$set(list(echo = FALSE, eval = FALSE))
knit("foo.Rmd")

This command will create output document foo.md only with text.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!