After using Windows Explorer to navigate to a directory, I just want to copy and paste the directory in R, but I get this error:
> setwd("C:\Program Files") Error: 'P' is an unrecognized escape in character string starting ""C:\P"
I used the setwd() function and pasted the directory, but there is an answer!
By using readline(), you can paste the directory in with no issues:
> setwd(readline()) C:\Program Files # This is where you paste
After hitting enter, you’ll be prompted for the directory. Paste the directory that you copied from Windows Explorer and voila!
You’ve changed your working directory with no path mucking.