Walks up from start until a folder holds one of the markers. The
default markers are a .git entry, a DESCRIPTION file, or any file that
ends in .Rproj. Scripts can then build paths from the root instead of
from the working directory.
Usage
project_root(start = ".", markers = c(".git", "DESCRIPTION", ".Rproj"))See also
project_path() to join paths under the root.
Examples
root <- fs::path(tempfile(), "study")
fs::dir_create(fs::path(root, "scripts", "qc"))
fs::file_create(fs::path(root, "DESCRIPTION"))
project_root(fs::path(root, "scripts", "qc"))
#> /tmp/RtmpacoIFD/file1a1145953f8/study
unlink(fs::path_dir(root), recursive = TRUE)