Reputation: 101
I get "cannot change working directory" error when I try to set up my working directory:
setwd("C:\Users\alimo\Desktop\DataVisualizationwithggplot2.R")
*Error: '\U' used without hex digits in character string starting ""C:\U"*
then I ran:
options(PACKAGE_MAINFOLDER="C:/Users/...")
and replaced all "" to "/" but I got this error this time:
cannot change working directory
Upvotes: 3
Views: 31814
Reputation:
Yes, writing a path to a file or directory can sometimes be a bit painful, especially when you move across different platforms!
setwd()
sets the working directory, so it means you need to specify a directory, not a file.
And whenever I'm not sure about the single/double (back)slashes, I like to use file.path()
from base R, which adds a correct delimiter in a platform-independent way:
file.path("~", "myfolder", "myfile.R")
So for your case:
setwd(file.path("C:", "Users", "alimo", "Desktop"))
Upvotes: 5