R闪亮应用程序中自动删除的临时文件-文件错误:无法打开连接 [英] Temp files automatically deleted in R shiny app - Error in file: cannot open the connection
问题描述
我创建了一个使用批处理文件自动运行的 R 闪亮应用程序.启动应用程序时一切正常,但第二天它崩溃了,我收到以下消息:
I created a R shiny app that automatically runs every day using a batch file. Everything works fine when lauching the app, but the next day it crashes and I get the following message:
Warning in file(open = "w+") :
cannot open file
'C:UsersertinAppDataLocalTempRtmpKiBPOURf3f835d1a66' : No such file or directory
Warning: Error in file: cannot open the connection
[No stack trace available]
实际上这个问题与由 R 会话执行闪亮的应用程序创建的 tempdir()
文件夹有关.此文件夹会在一定时间后自动删除.我是否必须在每次刷新时删除所有临时文件?或者相反,是否需要防止 R 删除 Temp 文件夹中所有闪亮的临时文件?谢谢!
Actually this issue is related to the tempdir()
folder created by the R session executing the shiny app. This folder is automatically deleted after a certain time. Do I have to delete all Temp files on each refreshing? Or on the contrary is it needed to prevent R from deleting all shiny temp files on Temp folder? Thanks!
编辑 - 以下是故意生成错误的方法:
Edit - Here is how to intentionally generate the error:
tempdir()
dir.exists(tempdir())
library(shiny)
# Windows shell required
shinyApp(
ui = fluidPage("Please reload to see me fail."),
server = function(input, output) {
shell(paste("rmdir", dQuote(
normalizePath(tempdir(), winslash = "/", mustWork = FALSE), q = FALSE
), "/s /q"))
}
)
推荐答案
现在我在 Windows 10 (Storage Sense) 中找到了一个关于删除临时文件的设置,它似乎默认处于活动状态.
By now I've found a setting in Windows 10 (Storage Sense) concerning the deletion of temporary files, which seems to be active by default.
如下导航并取消选中:
- 设置
- 系统存储
- 存储感知
- 改变我们自动释放空间的方式
- 删除我的应用未使用的临时文件
这篇关于R闪亮应用程序中自动删除的临时文件-文件错误:无法打开连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!