Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
402 views
in Technique[技术] by (71.8m points)

r markdown - rmarkdown::render loop stalls after a few iterations

I am trying to generate a large number of html files using rmarkdown::render in a loop, with Parameterized reports.

After generating a number of files, it stalls, and I have to restart RStudio. I can generate each individual file in itself; it is not at the same file it stalls each time when I try running the loop.

There is no error message, making it hard for me to debug.

I have tried the following, none of which helped:

  • Closing all other programs; reducing the memory used.
  • Adding knitr::knit_meta(clean = TRUE) before render
  • Adding clean = T inside render
  • Calling render with callr::r
  • Including rm([[data]]); gc() at the end of the .rmd file that is called by render

Any other ideas of how to try and solve this issue?

question from:https://stackoverflow.com/questions/66049032/rmarkdownrender-loop-stalls-after-a-few-iterations

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Taking This from R Markdown: The Definitive Guide Where an example is used to render multiple files. Every file would have a it's own name regarding it's param region and year.

render_report = function(region, year) {
  rmarkdown::render(
    "MyDocument.Rmd", params = list(
      region = region,
      year = year
    ),
    output_file = paste0("Report-", region, "-", year, ".html")
  )
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...