简体   繁体   English

“警告:临时文件中的错误:在渲染多个 R 降价时找不到未使用的临时文件名”

[英]'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) .我有一个过程,它使用rmarkdown::render(template_file, output_file)将多个 R markdown 文档顺序呈现并保存到一个目录中。

I'm finding that when the process goes over 100 rendered documents it stops with this message:我发现当进程超过 100 个渲染文档时,它会停止并显示以下消息:

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?我怀疑 knit/pandoc 过程中存在与导致此问题的中间文件相关的某些问题,但想知道是否有其他人以前遇到过这样的问题?

I have this issue in using rpy2 , looping an R code trunk again and again.我在使用rpy2时遇到了这个问题,一次又一次地循环 R 代码中继。 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.但是,我的代码使用难以跨平台更改的 3rd 方包。 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.希望这能解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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