First compose an absolute path using the project root directory and the
relative path components, i.e.,
file.path(root, ...). Then
convert it to a relative path with
relative_path(), which is
relative to the current working directory.
from_root(..., root = proj_root(), error = TRUE)
A character vector of path components relative to the root directory of the project.
The root directory of the project.
Whether to signal an error if the path cannot be converted to a relative path.
This function was inspired by
here::here(), and the major difference
is that it returns a relative path by default, which is more portable.
A relative path, or an error when the project root directory cannot
be determined or the conversion failed and
error = TRUE.
## Not run: xfun::from_root("data", "mtcars.csv") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.