I'm creating a reference document with snippets of code from various Rmd files.
For example, my first file looks like this:
lm.Rmd
:
---
title: Linear Models
---
# How to Run Linear Models
```{r}
lm(am ~ cyl + mpg, data = mtcars)
```
## Linear Model Results
...
# A New Linear Model
...
and then in a second file (using Quarto qmd now), I'm trying to reference this external script and have it be displayed as raw Rmd code, not as HTML or Markdown output. Here's what I'm trying:
reference.qmd
:
---
title: Reference Document
---
# Linear Model Scripts
Here is the script we used for linear models:
```{r}
#| file: dir/lm.Rmd
#| eval: false
#| echo: true
#| code-folding: true
```
# More Scripts
...
What I want is the raw RMD/QMD code to be included in the 'echoed' code box on the final reference.qmd
HTML document. But what is happening is that the markdown from the lm.Rmd
file is being evaluated and is getting displayed as if I had written it directly in the reference.qmd
document.
In the end, what I want is to be able to display any arbitrary external script and have the end-user be able to scroll through that script in the final HTML output (a QMD book in this case). The file:
option in the QMD code chunk seems to get me partially there, as it works well for .R
files, but it doesn't seem to work for .Rmd
files.
I was successful in Quarto and pdf with this solution:
```{r}
#| echo: true
#| eval: false # skip evaluation
#| file: C:/directory/script.R
```