【问题标题】:Why are permissions denied writing this file from R? [duplicate]为什么权限被拒绝从 R 写入此文件? [复制]
【发布时间】:2020-08-28 22:15:43
【问题描述】:

我正在尝试将一些数据从 R 导出到 .csv。它昨天工作,但今天我收到此错误消息:

Error in file(file, ifelse(append, "a", "w")) : 
  cannot open the connection
In addition: Warning message:
In file(file, ifelse(append, "a", "w")) :
  cannot open file 'C:/Users/cgarf/Documents/OTL_Model': Permission denied

我最近更改了 java 版本。我不确定这是否会导致问题,或者我是否遗漏了什么

【问题讨论】:

  • 请检查属性中的文件夹权限
  • 权限由您的操作系统处理,而不是 R。所以这真的不是 R 问题。您可能无法使用当前用户帐户从任何应用程序写入该文件夹。

标签: r permissions


【解决方案1】:

该错误通常是因为您试图将文件写入目录

file.exists("quux")
# [1] FALSE
dir.create("quux")
file.exists("quux")
# [1] TRUE
dir.exists("quux")
# [1] TRUE
write.table(mtcars, "quux")
# Warning in file(file, ifelse(append, "a", "w")) :
#   cannot open file 'quux': Permission denied
# Error in file(file, ifelse(append, "a", "w")) : 
#   cannot open the connection

顺便说一句,如果它可以帮助您缩小 where 正在使用的目录(而不是文件名),我只是 greped R 源(基础库)并找到了两个实例ifelse(append, "a", "w"):

(这些链接在提交 5b2f6e4 时“现在”提供。)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-18
    • 2015-11-24
    • 1970-01-01
    • 2023-04-01
    • 2018-08-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多