Debian Codegraph @

man/from_root.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/paths.R
3 \name{from_root}
4 \alias{from_root}
5 \title{Get the relative path of a path in a project relative to the current working
6 directory}
7 \usage{
8 from_root(..., root = proj_root(), error = TRUE)
9 }
10 \arguments{
11 \item{...}{A character vector of path components \emph{relative to the root
12 directory of the project}.}
13
14 \item{root}{The root directory of the project.}
15
16 \item{error}{Whether to signal an error if the path cannot be converted to a
17 relative path.}
18 }
19 \value{
20 A relative path, or an error when the project root directory cannot
21 be determined or the conversion failed and \code{error = TRUE}.
22 }
23 \description{
24 First compose an absolute path using the project root directory and the
25 relative path components, i.e., \code{\link{file.path}}\verb{(root, ...)}. Then
26 convert it to a relative path with \code{\link[=relative_path]{relative_path()}}, which is
27 relative to the current working directory.
28 }
29 \details{
30 This function was inspired by \code{here::here()}, and the major difference
31 is that it returns a relative path by default, which is more portable.
32 }
33 \examples{
34 \dontrun{
35 xfun::from_root("data", "mtcars.csv")
36 }
37 }