Chained setup chunks

library(learnr)
d <- 3

Addition

We'll start the setup chunk chain with a regular chunk called setupA:

```r
a <- 5 
``` 
a <- 5 

Use exercise.setup to chain setup chunks. Let's start with a simple, single, setup chunk called setupB that depends on setupA.

```r
b <- a + d
``` 
b <- a + d

Then we define an exercise, ex1, that uses setupB as its setup chunk, thereby also using setupA for the exercise.

```r 
x = b + 1
x
```
x = b + 1
x

Evaluate the code in the above exercise. The result of x should be 9.

Now let's define another exercise, ex2, that uses the pre-filled code from ex1 for its setup code, thereby also depending on setupB and setupA.

```r
y <- x + 1
y
```
y <- x + 1
y

Evaluate the code in the above exercise. The result of y should be 10.



Try the learnr package in your browser

Any scripts or data that you put into this service are public.

learnr documentation built on Sept. 28, 2023, 9:06 a.m.