R set working directory using copy and paste

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:

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:

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.

About the Author

Ray Li

Ray is a software engineer and data enthusiast who has been blogging for over a decade. He loves to learn, teach and grow. You’ll usually find him wrangling data, programming and lifehacking.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.