我想知道为什么它不允许我更改我的工作目录。
我一直看到这个错误:
Error in setwd(dataDir) : cannot change working directory
这是我的代码:
dataDir <- "C:/Documents and Settings/My Documents/R/"
setwd(dataDir)
我想知道为什么它不允许我更改我的工作目录。
我一直看到这个错误:
Error in setwd(dataDir) : cannot change working directory
这是我的代码:
dataDir <- "C:/Documents and Settings/My Documents/R/"
setwd(dataDir)
似乎是一个烦人的 Windows 权限问题;那是一个遗留目录。Google 有 293 万次点击“Windows (7/)10: Access to the path 'C:\Documents and Settings' is denied”。在 Windows 论坛中寻求建议,并检查“C:/Documents and Settings/My Documents/...”的所有权和权限当前是什么,它们应该是什么,以及是否启用了管理员帐户。(坦率地说,不是 R 安装包目录的最佳选择,但许多安装程序使用它,或者默认使用它。)
setwd()
适用于更无害的目录选择,例如 'C:\Users\your_name\R'路径一定有错误。它应该看起来像C:\<your_username>\Documents and Settings\My Documents
或者试试
setwd("C:\\[your_username]\\Documents and Settings\\My Documents\\R")
“文档和设置”是一个存在于真正旧版本的 Windows(XP 和更早版本)中的目录。在 Windows 10 中,您的用户数据位于 下C:\users\<username>
,您的文档位于C:\users\<username>\Documents
.
就 R 而言,在 Windows 10 下,主目录~
映射到C:\users\<username>\Documents
.
以管理员身份运行 Rstudio。然后运行dataDir <- "C:/Documents and Settings/My Documents/R/" setwd(dataDir strong text**)**