我想知道为什么它不会让我改变我的工作目录 我一直看到这个错误:
Error in setwd(dataDir) : cannot change working directory
这是我的代码:
dataDir <- "C:/Documents and Settings/My Documents/R/"
setwd(dataDir)
答案 0 :(得分:1)
似乎是一个恼人的Windows权限问题;这是一个遗留目录。 按照“Windows(7 /)10:对路径'C:\ Documents and Settings'的访问被拒绝”,有293万次谷歌点击。在Windows论坛中寻找建议,并检查当前“C:/ Documents and Settings / My Documents / ...”的所有权和权限,以及它们应该是什么,以及是否启用了Administrator帐户。 (坦率地说,不是R安装包目录的最佳选择,但许多安装程序使用它,或默认使用它。)
setwd()
适用于更无害的目录选择,例如'C:\用户\ your_name \ R'答案 1 :(得分:0)
路径中必须存在错误。它看起来应该像C:\<your_username>\Documents and Settings\My Documents
或尝试
setwd("C:\\[your_username]\\Documents and Settings\\My Documents\\R")
答案 2 :(得分:0)
“文档和设置”是在真正较旧的Windows版本(XP和更早版本)中存在的目录。在Windows 10中,用户数据位于C:\users\<username>
下,而文档位于C:\users\<username>\Documents
中。
就R而言,在Windows 10下,主目录~
映射到C:\users\<username>\Documents
。
答案 3 :(得分:0)
以Admin身份运行Rstudio。 然后运行 dataDir <-“ C:/ Documents and Settings / My Documents / R /” setwd(dataDir 强文本**)**