This package helps accessing files relative to a project root to stop the working directory insanity.
The source for this text is in the readme
subdirectory:
basename(getwd())
#> [1] "readme"
How do we access the package root? In a robust fashion? Easily:
dir(rprojroot::find_root("DESCRIPTION"))
#> [1] "appveyor.yml" "cran-comments.md" "DESCRIPTION"
#> [4] "docs" "inst" "Makefile"
#> [7] "man" "NAMESPACE" "NEWS.md"
#> [10] "_pkgdown.yml" "R" "readme"
#> [13] "README.md" "rprojroot.Rproj" "scripts"
#> [16] "tests" "vignettes"
Install from GitHub:
devtools::install_github("krlmlr/rprojroot")
See the documentation for more detail.