6
votes

I have r script containing a loop in which I call rmarkdown::render() to create multiple HTML reports.The process worked well until I started to generate larger report files (which make me think about a memory problem...).

After a few successful iteration, the process stops with this message in the R console: Error: pandoc document conversion failed with error 1033.

Here is how the render() function is used inside the loop :

for (i in 1:length(random_vector)) {
  id = random_vector[i]

  knitr::knit_meta(class=NULL, clean = TRUE) # does not prevent the problem

  rmarkdown::render("my_rmd_file_that_generates_reports.Rmd", 
                    output_file = paste(id_fiche, "report.html"))

}

This error is not mentioned here : https://pandoc.org/help.html and does not correspond to this one : https://github.com/jgm/pandoc/issues/1033. The idea mentionned here rmarkdown::render() in a loop - cannot allocate vector of size using this line:knitr::knit_meta(class=NULL, clean = TRUE) is not solving this problem.

NOTE: I can not give a reproductible exemple as I do not know the precise origin of the problem, I hope someone faced the same problem and found a way to takle it.

Session info :

R version 3.6.0 (2019-04-26)

Platform: x86_64-w64-mingw32/x64 (64-bit)

Running under: Windows 10 x64 (build 18362)

[EDIT] Here is the pandoc version I am using :

>pandoc_version()
[1] ‘2.6’
2
Could you add which pandoc version is installed? This post says that updating pandoc resolved the problem.tarleb
FWIW, here is a list of pandoc error codes. 1033 is not among them, the error is likely thrown by R as a response to unexpected pandoc behavior.tarleb
@tarleb I have added the output of rmarkdown::pandoc_version() in the post. I am using the version 2.6 of pandoc. I will update it and give a feedback, thanks for your suggestion.Paul
@tarleb Updating pandoc to version 2.7.3 solved the problem, I thought it was maintained updated but I was wrong. Many thanks for your suggestion. Feel free to post your comment as an answer so I can validate it as a solution.Paul

2 Answers

8
votes

Here is the process that solved the error. The idea comes from @tarleb's comment. Error 1033 is not a Pandoc error ; it is not referenced here : https://github.com/jgm/pandoc/blob/master/MANUAL.txt#L1384.

And it is not the memory usage problem that can be solved with knitr::knit_meta(class=NULL, clean = TRUE)

As suggested here, update Pandoc can be the solution.

  1. Using rmarkdown::pandoc_version() check the pandoc version currently used to generate the Rmarkdown reports.
  2. Go on this website : https://pandoc.org/releases.html and check if the version you are using is the latest one.

For me it was not the case (I was using v2.6 of Pandoc and last one was v2.7.3) So I followed the tutorial from this page : https://pandoc.org/installing.html.

Then I checked if rmarkdown::pandoc_version() returned the latest version number and I reran my R script. It solved the problem.

1
votes

A small tip: what I need to add is that when I installed Pandoc for the first time, I choose private user instead of public. Thus, after input rmarkdown::pandoc_version() in R gave 2.60 still. So it is better to choose to install for public.