Learn R Programming

this.path (version 2.2.0)

this.proj: Construct Path to File, Starting with the Project's Directory

Description

sys.proj(), env.proj(), src.proj(), and this.proj() construct paths to files starting with the project's root.

reset.proj() will reset the paths cached by these functions. This can be useful if you created a new project in your R session that you would like to be detected without the need to restart the R session.

Usage

sys.proj(..., local = FALSE)
env.proj(..., n = 0, envir = parent.frame(n + 1),
         matchThisEnv = getOption("topLevelEnvironment"))
src.proj(..., n = 0,
         srcfile = if (n) sys.parent(n) else 0)

this.proj(..., local = FALSE, n = 0, envir = parent.frame(n + 1), matchThisEnv = getOption("topLevelEnvironment"), srcfile = if (n) sys.parent(n) else 0)

reset.proj()

Value

A character vector of the arguments concatenated term-by-term, starting with the project's root.

Arguments

...

further arguments passed to path.join().

local

See ?sys.path().

n, envir, matchThisEnv, srcfile

See ?this.path().

Details

Unlike here::here(), these functions support sub-projects and multiple projects in use at once, and will choose which project root is appropriate based on sys.dir(), env.dir(), src.dir(), or this.dir(). Additionally, it is independent of working directory, whereas here::here() relies on the working directory being set within the project's directory when the package is loaded. Arguably, this makes it better than here::here().