r - 设置工作目录: "Error in setwd: cannot change working directory" under "C:/Documents and Settings/..."

标签 r windows-10 working-directory setwd

我想知道为什么它不允许我更改我的工作目录。
我不断看到此错误:

Error in setwd(dataDir) : cannot change working directory

这是我的代码:

dataDir <- "C:/Documents and Settings/My Documents/R/"
setwd(dataDir)

最佳答案

似乎是一个烦人的 Windows 权限问题;那是一个遗留目录。 类似“Windows (7/)10:访问路径‘C:\Documents and Settings’被拒绝”的 Google 搜索次数达到 293 万次。。在 Windows 论坛中查找建议,并检查“C:/Documents and Settings/My Documents/...”当前的所有权和权限是什么,它们应该是什么,以及是否启用了管理员帐户。 (坦率地说,这不是 R 安装包目录的最佳选择,但许多安装程序都使用它,或者默认使用它。)

  • 请确认 setwd() 对于更无害的目录选择可以正常工作,例如'C:\Users\your_name\R'
  • 您是以管理员还是用户身份运行 R?
  • 您是以管理员还是用户身份安装 R 的? (您使用了哪个安装程序,哪个安装程序版本/日期?R 项目的?Anaconda?另一个?)

关于r - 设置工作目录: "Error in setwd: cannot change working directory" under "C:/Documents and Settings/...",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50224150/

相关文章:

r - 如何以 F1 作为度量而不是准确性来训练非二元分类 rpart?

r - 使用与 hist() 和plot() 配合使用的替代命令时出现箱线图错误

powershell - Chocolatey 在安装 openvpn 时返回错误

python - 如何将VS代码工作目录更改为运行文件目录

python-3.x - 如何更改 Jupyter 实验室工作目录

scala - 如何获取 Scala 中的当前(工作)目录?

r - 如何使用 R 最小化线性规划模型的设置成本

r - 自定义R markdown pdf文档

windows-10 - 在 JDK9 中禁用 BufferedImage 的自动缩放

windows - 是否有一个 API 可以通过 win32 应用程序在 Windows 8 或 Windows 10 触摸笔记本电脑上自动弹出虚拟键盘