I would like to be able to write exercise hints displaying randomly generated values. Here's a MWE:
---
title: "learnr"
output: learnr::tutorial
runtime: shiny_prerendered
---
```{r setup, include = FALSE}
library(learnr)
vals <- sample(1:10, 3)
```
## Edit hints of an exercise
**Question:** How can you compute the mean of the values `r paste0(vals, collapse=", ")` in R?
```{r ex1, exercise = TRUE}
```
```{r ex1-solution}
# Here, I would like to render the R code
mean( c(vals[1], vals[2], vals[3]) )
# where vals[i] are the values which appear in the question.
# I can't just type them in since they are randomly generated.
```
Press the Solution button to see the problem.
You can see how it looks below:
How can this be done?
Thank you in advance.