1

I have R scripts in my laptop, developed by another teammate.

These use setwd() function with a harcoded path.

Now I would like to add these scripts to github, and these harcoded paths are a problem because each developer has the github's project in their own path, without a pattern.

How can we get the file path itself, independent of where R points as a working directory?

mrc
  • 2,845
  • 8
  • 39
  • 73
  • Maybe `getwd()`? – Rui Barradas Jun 19 '19 at 13:48
  • 2
    If you work with RStuio projects you might be interested in the **here** package. I also saw [this question](https://stackoverflow.com/questions/47044068/get-the-path-of-current-script/47045368), which looks relevant. – aosmith Jun 19 '19 at 13:52
  • 2
    Also see `rprojroot::this_file()`, although that comes with a lot of warnings about finding alternative options if possible. ;) The related SO post is [here](https://stackoverflow.com/questions/1815606/determine-path-of-the-executing-script) – aosmith Jun 19 '19 at 13:57

0 Answers0