1

I am currently working on a joint project, with all the files stored in a Dropbox. To avoid changing the working directory every time we change something, we use the following code:

this.dir = dirname(parent.frame(2)$ofile)
setwd(this.dir)

This is working fine when sourcing the code in Rstudio, but we are looking for a solution that is working outside RStudio.

The team is working on Mac and Windows.

  • If your team "sources" the .R file, you can find a solution there: http://stackoverflow.com/questions/3452086/getting-path-of-an-r-script – Eric Lecoutre Jun 15 '16 at 13:34
  • For this kind of operation github is perhaps the best solution. https://github.com/ – J_F Jun 15 '16 at 13:40

1 Answers1

1

For Windows, locate the file "Rprofile.site". In there, there will be set the following command setwd("PATH_TO_WD")

The same goes for Mac, the file is usually located at /etc/R/ path.

Just change the setwd in that file and everytime you launch R, the working directory will be set to the directory you want.

EDIT: In my Windows computer, the file is located at "C:\Program Files\R\R-3.2.3\etc

Felipe Sulser
  • 1,185
  • 8
  • 19