Skip to content
Prev 376823 / 398502 Next

Genuine relative paths with R

Hi Jeff,

Thanks for sharing your workaround.

I guess my last answer to Ista answers your question as well.

To me this function (an equivalent of 'cd', say) should be platform-independent.

Best regards,

Olivier

________________________________
De : Jeff Newmiller <jdnewmil at dcn.davis.ca.us>
Envoy? : samedi 6 octobre 2018 19:31
? : r-help at r-project.org; Olivier GIVAUDAN; r-help at r-project.org
Objet : Re: [R] Genuine relative paths with R

I stopped using hardcoded absolute paths inside R scripts years ago, and I suspect that is fairly common practice. That is, I almost never enter a path starting with "/" or "c:/" in an R script.

The key concession you have to make is to start your R session in your working directory using OS-specific mechanisms, and then reference your code and data relative to that directory. RStudio project files offer one mechanism for doing this; using CD from the OS command line is another, and using the file-browser double-click mechanism on .RData files is another (though I prefer to avoid that these days due to potential global environment contamination).

Perhaps you can be more specific about what facilities you are expecting to find. You should also mention what OS you typically use and how you normally start R.
On October 6, 2018 4:48:44 AM PDT, Olivier GIVAUDAN <olivier_givaudan at hotmail.com> wrote:
--
Sent from my phone. Please excuse my brevity.