RMarkdown where child markdowns which do not evaluate chunks results in unexpected output

Viewed 35

I have several markdowns which include intentional errors and placeholder code in the chunks. The goal is for students to find and fix errors/fill in the code to find the correct answer. Individually, they export perfectly, however when trying to bundle them together into a single markdown I run into issues.

I export the individual markdowns by setting eval and error both equal to FALSE. That way just the markdown with body text and placeholder code chunks are included.

Each individual markdown exports correctly, however when I try to bundle them together using chunks with the child argument (see examples below), they only knit the first markdown, and then will not knit any of the following markdowns.

I believe that the eval argument is staying equal to FALSE even when I explicitly change it back to TRUE. I've experimented with different settings, placing the arguments in both the parent and the child markdowns, and just general tinkering.

I cant seem to figure out a solution. Any help would be greatly appreciated!

Example Child Markdown

No YAML Header present. I added periods after backticks so they do not create a new code chunk.

```{r, include = FALSE}
#used for export
knitr::opts_chunk$set(eval = FALSE, error = FALSE)
```

Some body text with chunks of code. None are meant to run and there are intentional errors.

This markdown will export correctly until it is added to the parent markdown

###Question 1

```{r}

setwd()

```

###Question 2

```{r}

plot()

```

etc....

```{r, include = FALSE}
#used for resetting eval and error for the parent markdown
knitr::opts_chunk$set(eval = TRUE, error = TRUE)
```

Example Parent Markdown

---
title: "Mastery Check Full"
author: "Dillon Jones"
date: "2022-07-25"
output:
  html_document:
    toc: yes
    toc_depth: 1
  pdf_document:
    toc: yes
    toc_depth: 1

---

## Section 0 Mastery Check

```{r, child = "Section 0 Mastery Check.Rmd"}
```

\newpage

## Section 1 Mastery Check

```{r, child = "Section 1 Mastery Check.Rmd"}
```

\newpage

## Section 2 Mastery Check

```{r, child = "Section 2 Mastery Check.Rmd"}
```

\newpage

## Section 3 Mastery Check

```{r, child = "Section 3 Mastery Check.Rmd"}
```

Example Output

Section 0 Mastery Check

Some body text with chunks of code. None are meant to run and there are intentional errors.

This markdown will export correctly until it is added to the parent markdown

Question 1


setwd()

Question 2


plot()

etc...

Section 1 Mastery Check

Section 2 Mastery Check

Section 3 Mastery Check

0 Answers
Related