Forum: support

Monitor Forum | Start New Thread Start New Thread
RE: How to insert ID in the pdf file name [ reply ]
By: Achim Zeileis on 2016-11-28 00:26
Unfortunately, this is not possible at the moment. You can just set the "name" prefix but then consecutive numbering is always added. As this information is passed through various functions (and not just the PDF writer), it is not trivial to change.

The quickest and safest solution is probably to use file.rename() after the files have been created. As that function is not vectorized, I often use a simple convenience wrapper rename_files() for such a task. The R code is given below.

Hope that helps...

rename_files <- function(x, y) {
stopifnot(length(x) == length(y))
rval <- logical(length(x))
for(i in seq(along = x)) rval[i] <- file.rename(x[i], y[i])

How to insert ID in the pdf file name [ reply ]
By: Walter Pereira on 2016-11-27 23:18

I am using exams to generate statistical tests with the alumn ID in the header.
Let suposse that are 10 students with ID 30140, 30141, ..., 30149, randomly chosen from a file. It would be possible to obtain: exam30140, solution30140, ...exam30149, solution30149, instead of: exam1, solution1, ...exam10, solution10.

exams2pdf("Testebio.Rnw", n = 1, dir = odir, template = c("exam", "solution"), header = list(ID = matri, Date = Sys.Date()))


Walter Pereira

Thanks to:
Vienna University of Economics and Business University of Wisconsin - Madison Powered By FusionForge