from_here {fromhere} | R Documentation |
Create a File Path Relative to a Project Root
Description
These functions generate file paths relative to the root of a specific type of project.
They use criteria from rprojroot
to locate the root directory and construct paths
using file.path()
.
Usage
from_here(...)
from_wd(...)
from_rproj(...)
from_r_package(...)
from_remake(...)
from_drake(...)
from_targets(...)
from_pkgdown(...)
from_renv(...)
from_projectile(...)
from_quarto(...)
from_git(...)
from_svn(...)
from_vcs(...)
from_testthat(...)
Arguments
... |
Character components of the relative file path. |
Details
Functions support two ways to specify paths: as function arguments
(e.g., from_r_package("path/to/file")
) or using the $
operator
(e.g., from_r_package$path$to$file
), which supports autocompletion.
The following from_*
functions are available:
-
from_here
: For paths relative to the{here}
package's automatic project root. -
from_rproj
: For R project directories. -
from_r_package
: For R package directories. -
from_remake
: For remake project directories. -
from_drake
: For drake project directories. -
from_targets
: For targets project directories. -
from_pkgdown
: For pkgdown project directories. -
from_renv
: For renv project directories. -
from_projectile
: For Projectile project directories. -
from_quarto
: For Quarto project directories. -
from_git
: For Git repository root directories. -
from_svn
: For SVN repository root directories. -
from_vcs
: For generic version control root directories (Git or SVN). -
from_testthat
: For testthat directories.
Value
A file path which allows further traversal with $
autocompletion.
See Also
Examples
# Construct a path from the current working directory
from_wd()
## Not run:
# Construct a path to a file in an R package
from_r_package("R", "my_file.R")
# Construct a path in a pkgdown project
from_pkgdown$docs$index.html
# Construct a path in a Git repository
from_git("src", "main.c")
## End(Not run)