gpt4 book ai didi

r - 在 R Shiny 应用程序中自动删除临时文件 - 文件 : cannot open the connection 中的错误

转载 作者:行者123 更新时间:2023-12-03 17:31:30 25 4
gpt4 key购买 nike

我创建了一个 R Shiny 的应用程序,它每天使用批处理文件自动运行。
启动应用程序时一切正常,但第二天它崩溃了,我收到以下消息:

Warning in file(open = "w+") :
cannot open file
'C:\Users\bertin\AppData\Local\Temp\RtmpKiBPOU\Rf3f835d1a66' : No such file or directory
Warning: Error in file: cannot open the connection
[No stack trace available]

其实这个问题与 tempdir()有关由执行 Shiny 应用程序的 R session 创建的文件夹。该文件夹会在一段时间后自动删除。我是否必须在每次刷新时删除所有 Temp 文件?或者相反,是否需要防止 R 删除 Temp 文件夹中的所有 Shiny 临时文件?谢谢!

编辑 - 以下是故意生成错误的方法:
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"))
}
)

result

最佳答案

到目前为止,我在 Windows 10 (Storage Sense) 中找到了一个关于删除临时文件的设置,默认情况下它似乎处于事件状态。

导航如下和取消勾选 :

  • 设置
  • 系统存储
  • 存储感知
  • 更改我们自动释放空间的方式
  • 删除我的应用程序未使用的临时文件

  • Windows Storage Sense

    关于r - 在 R Shiny 应用程序中自动删除临时文件 - 文件 : cannot open the connection 中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53152076/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com