Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

expar

Fix Parameters in Dynamic Exercises


Description

Set parameters, defined in the first code chunk of an exercise file, to specific values instead of their definition in the exercise file.

Usage

expar(file, ...)

Arguments

file

character with (path to) an exercise file.

...

paramters to be fixed within file (or a single list of parameters to be fixed).

Details

To set certain parameters that are randomly generated within an exercise file to specific values, a copy of the exercise file is generated in the temporary directory of the R session. In the temporary copy of the exercise file the first assignment to the specified parameter in the first code chunk is replaced with the definition provided in expar.

To work properly, the parameter of interest must be defined with a standard assignment in the first code chunk at the beginning of a line. The original definition of the parameter must be in a single line only (typically using something like sample or runif etc.).

After replacing the code chunk, expar returns the path to the temporary file with the modified exercise. This can then be processed with exams2xyz "as usual".

Value

A character string with the file path of the modified exercise.

Examples

## fix parameters "a" and "c" in deriv.Rmd
## (but still generate "b" randomly)

## HTML output
if(interactive()){
exams2html(expar("deriv.Rmd", a = 1, c = 0))
}

## just the question text
x <- xexams(expar("deriv.Rmd", a = 1, c = 0))
writeLines(x[[1]][[1]]$question)

exams

Automatic Generation of Exams in R

v2.3-6
GPL-2 | GPL-3
Authors
Achim Zeileis [aut, cre] (<https://orcid.org/0000-0003-0918-3766>), Bettina Gruen [aut] (<https://orcid.org/0000-0001-7265-4773>), Friedrich Leisch [aut] (<https://orcid.org/0000-0001-7278-1983>), Nikolaus Umlauf [aut], Mirko Birbaumer [ctb], Dominik Ernst [ctb], Patrik Keller [ctb], Niels Smits [ctb], Reto Stauffer [ctb], Kenji Sato [ctb]
Initial release
2020-04-05

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.