library(learnr) d <- 3
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
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.