I am trying to use R/exams with an exercise that reads a local data set. The code from the exercise works fine when I run it interactively but it fails when I run it in exams2moodle()
. The same issue occurs when I try to source()
an R script within the exercise.
A simplified artificial example is included below.
library("exams")
exams2moodle("mysum.Rmd")
The exercise file mysum.Rmd
is:
```{r, include=FALSE}
i <- sample(1:3, 1)
d <- read.csv("mydata.csv")
s <- d$x[i] + d$y[i]
```
Question
========
What is the sum of $`r i`$ + $`r i+1`$?
Meta-information
================
exname: mysum
extype: num
exsolution: `r s`
And the data file mydata.csv
is:
x,y
1,5
8,3
4,4