简体   繁体   中英

'Warning: Error in tempfile: cannot find unused tempfile name' when rendering multiple R Markdowns

I have a process which renders and saves multiple R markdown documents sequentially into a directory, using rmarkdown::render(template_file, output_file) .

I'm finding that when the process goes over 100 rendered documents it stops with this message:

Warning: Error in tempfile: cannot find unused tempfile name

I suspect there is something in the knit/pandoc process relating to intermediate files that is causing this, but wondering if anyone else has come across an issue like this before?

I have this issue in using rpy2 , looping an R code trunk again and again. It happens only after certain number of loops. Remove temp files or reduce the number of temp files used in the first place should solve the problem.

However, my code using 3rd party packages which is hard to change across platforms. So I just remove all temp files.

I solved the problem by adding this to my code:

sapply(file.path(tempdir(), list.files(tempdir())), unlink)

Then I restart some code that might use the temp file I deleted.

Hope this will solve your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM