Explore Courses Blog Tutorials Interview Questions
0 votes
in R Programming by (5.3k points)

I am working out some tutorials in R. Each R code is contained in a specific folder. There are data files and other files in there. I want to open the .r file and source it such that I do not have to change the working directory in Rstudio as shown below:

enter image description here

Is there a way to specify my working directory automatically in R.

1 Answer

0 votes
edited by

To set the working directory to the source file location, you can do the following:

To get the source file directory:


To set the working directory to source file directory:


Browse Categories