我想知道为什么它不让我改变我的工作目录。我一直看到这个错误:
Error in setwd(dataDir) : cannot change working directory
字符串这是我的代码:
dataDir <- "C:/Documents and Settings/My Documents/R/"setwd(dataDir)
dataDir <- "C:/Documents and Settings/My Documents/R/"
setwd(dataDir)
型
qni6mghb1#
这似乎是一个恼人的Windows权限问题;这是一个遗留目录。有293万个谷歌点击量,沿着 “Windows(7/)10:访问路径'C:\Documents and Settings'被拒绝”。在Windows论坛中寻找建议,并检查“C:/Documents and Settings/My Documents/...”上的所有权和权限是什么,它们应该是什么,以及是否启用了管理员帐户。(坦率地说,这不是R安装包目录的最佳选择,但许多安装程序使用它,或默认为它。)
setwd()
wpcxdonn2#
路径中一定有错误,应该是C:\<your_username>\Documents and Settings\My Documents或尝试setwd("C:\\[your_username]\\Documents and Settings\\My Documents\\R")个
C:\<your_username>\Documents and Settings\My Documents
setwd("C:\\[your_username]\\Documents and Settings\\My Documents\\R")
qlzsbp2j3#
“文档和设置”是一个存在于旧版本Windows(XP及更早版本)中的目录。在Windows 10中,您的用户数据位于C:\users\<username>下,而您的文档位于C:\users\<username>\Documents下。就R而言,在Windows 10下,主目录~Map到C:\users\<username>\Documents。
C:\users\<username>
C:\users\<username>\Documents
~
cig3rfwq4#
以管理员身份运行Rstudio,然后运行dataDir <-“C:/Documents and Settings/My Documents/R/”setwd(dataDirstrong text**)**
v2g6jxz65#
我也有同样的错误,原来是我把目录的位置从桌面改到了文档,再检查一下你的文件位置,可能是这个问题。
5条答案
按热度按时间qni6mghb1#
这似乎是一个恼人的Windows权限问题;这是一个遗留目录。有293万个谷歌点击量,沿着 “Windows(7/)10:访问路径'C:\Documents and Settings'被拒绝”。在Windows论坛中寻找建议,并检查“C:/Documents and Settings/My Documents/...”上的所有权和权限是什么,它们应该是什么,以及是否启用了管理员帐户。(坦率地说,这不是R安装包目录的最佳选择,但许多安装程序使用它,或默认为它。)
setwd()
对于无害性更高的目录选择(例如“C:\Users\your_name\R”)工作正常wpcxdonn2#
路径中一定有错误,应该是
C:\<your_username>\Documents and Settings\My Documents
或尝试
setwd("C:\\[your_username]\\Documents and Settings\\My Documents\\R")
个qlzsbp2j3#
“文档和设置”是一个存在于旧版本Windows(XP及更早版本)中的目录。在Windows 10中,您的用户数据位于
C:\users\<username>
下,而您的文档位于C:\users\<username>\Documents
下。就R而言,在Windows 10下,主目录
~
Map到C:\users\<username>\Documents
。cig3rfwq4#
以管理员身份运行Rstudio,然后运行dataDir <-“C:/Documents and Settings/My Documents/R/”setwd(dataDirstrong text**)**
v2g6jxz65#
我也有同样的错误,原来是我把目录的位置从桌面改到了文档,再检查一下你的文件位置,可能是这个问题。