I was wondering why it won't let me change my working directory.
I keep seeing this error:
Error in setwd(dataDir) : cannot change working directory
This is my code:
dataDir <- "C:/Documents and Settings/My Documents/R/"
setwd(dataDir)
I was wondering why it won't let me change my working directory.
I keep seeing this error:
Error in setwd(dataDir) : cannot change working directory
This is my code:
dataDir <- "C:/Documents and Settings/My Documents/R/"
setwd(dataDir)
Seems to be an annoying Windows permissions issue; that's a legacy directory. There are 2.93 million Google hits along the lines of "Windows (7/)10: Access to the path 'C:\Documents and Settings' is denied". Look for advice in Windows forums, and check what the ownership and permissions on "C:/Documents and Settings/My Documents/..." are currently, and what they're supposed to be, and whether Administrator account is enabled. (Frankly not the best choice for the R install packages directory, but many installers use it, or default to it.)
setwd()
works fine for a more harmless choice of directory, e.g. 'C:\Users\your_name\R'"Documents and Settings" is a directory that exists in really old versions of Windows (XP and earlier). In Windows 10, your user data is under C:\users\<username>
, and your documents are in C:\users\<username>\Documents
.
As far as R is concerned, under Windows 10 the home directory ~
maps to C:\users\<username>\Documents
.
Run Rstudio as Admin. then run dataDir <- "C:/Documents and Settings/My Documents/R/" setwd(dataDirstrong text**)**