1

When creating worksheets with exams2pdf() from R/exams, I like to repeat an exercise file multiple times to yield different numbers. However, when I include two plots in an exercise (e.g., one in the question and one in the solution) this yields:

Error in exm[[dups[j]]] : subscript out of bounds

A reproducible example is included below. It works with one plot, and it works if I don't repeat the question. Also, the problem can be avoided by making multiple copies of a simple.Rmd (say simple1.Rmd and simple2.Rmd with different chunk names in each copy) but it seems there should be a better way.

The Rmd file: simple.Rmd

Question
========
A question.
```{r drawit}
x = (-330):330/100
y = dnorm(x)
plot(x,y)
```

Solution
========
Let's redraw...
```{r drawagain}
x2 = (-330):330/100+100
y2 = dnorm(x2,mean=100,sd=1)
plot(x2,y2)
```

Meta-information
============
extype: num
exsolution: 10
exname: calc

And the replication R code:

library("exams")
q1 = "simple.Rmd"
probs = c(q1,q1)
exams2pdf(probs)

The Rmd file will knit fine (with two plots) but running the code above yields the above mentioned

Error in exm[[dups[j]]] : subscript out of bounds
4

1 回答 1

0

感谢您报告此问题,这是一个错误exams2pdf()!已更正单个重复的补充名称,但未更正多个重复的补充名称。我刚刚对 R-Forge 上的存储库进行了修复以解决该问题。

如果您可以从 R-Forge 安装软件包的开发版本以测试该修复程序是否也适用于您的实际用例,那就太好了。您可以通过以下方式从 R 中安装:

install.packages("exams", repos="http://R-Forge.R-project.org")
于 2019-09-18T01:00:30.157 回答