exams2pdf(file, n = 1L, nsamp = NULL, dir = ".", template = NULL,
inputs = NULL, header = list(Date = Sys.Date()), name = NULL,
control = NULL, encoding = "", quiet = TRUE, transform = NULL,
edir = NULL, tdir = NULL, sdir = NULL, verbose = FALSE,
points = NULL, …)
make_exams_write_pdf(template = "plain", inputs = NULL,
header = list(Date = Sys.Date()), name = NULL, quiet = TRUE,
control = NULL)
file
.file
. Sampling without replacement is used
if possible. (Only if some element of nsamp
is larger than
the length of the corresponding element in file
, sampling
with replacement is used.)dir
is explicitly specified, the file is displayed on the
screen rather than saved in dir
."exam"
, "solution"
, "plain"
,
among others. The default is to use the "plain.tex"
file unless
there are Rmd exercises in file
for which "plain8.tex"
is used. For further details see below.edir
.template
.xweave
.xexams
(by default no transformation is used).file
are stored (see also below).tempdir
. Note that this
is cleaned up and potentially temporary files are deleted.tempdir
.expoints
tags
of the exercise files (if any). The vector of points supplied should either have
length 1 or the number of exercises in the exam.xweave
.exams2pdf
returns a list of exams as generated by xexams
. make_exams_write_pdf
returns a function that is suitable for being
supplied as driver$write
to xexams
.exams2pdf
is a more flexible re-implementation of the old (version 1)
exams
function (Gruen and Zeileis 2009), using the new extensible
xexams
framework (Zeileis et al. 2014). A detailed
introduction is provided in vignette("exams", package = "exams")
, also
pointing out relative advantages of the new interface. exams2pdf
proceeds by using make_exams_write_pdf
to set up a custom
driver$write
function on the fly before calling xexams
.
This custom driver combines each exams with the desired template
(and inputs
etc.) and then calls texi2dvi
on the resulting LaTeX file to produce PDF output.
For a single exam (n = 1
) the resulting PDF is displayed on
screen (unless dir
is explicitly specified) while for n > 1
the PDF files are stored in the output directory dir
.xexams
,
exams
,
texi2dvi
## load package and enforce par(ask = FALSE)
options(device.ask.default = FALSE)
if(interactive()) {
## compile a single random exam (displayed on screen)
exams2pdf(list(
"boxplots",
c("tstat", "ttest", "confint"),
c("regression", "anova"),
"scatterplot",
"relfreq"
))
}
Run the code above in your browser using DataLab