Marc
Marc

Reputation: 11

Setting a working directory from another drive in R

I have a file which is saved on a different drive than RStudio and I'm trying to set it as the working directory.

setwd(dir) 

Where dir is the copy and pasted file path(windows) string. I get the error

 Error in setwd("dir") : 
  cannot change working directory

Since dir has been copied as a path, I cannot work out what the error might be.

Edit: I should have mentioned I have changed the all the \ to / in the file path.

Solved: quotation marks needed around file path.

Upvotes: 1

Views: 3252

Answers (1)

Jim
Jim

Reputation: 51

You should paste the windows path and change backslashes to forward slashes. Did you do this?

setwd("Z:/path") 

Upvotes: 1

Related Questions