From where? fromhere!

Lifecycle: experimental CRAN status R-CMD-check

The fromhere R package helps you create file paths relative to various project roots. It is inspired by the popular {here} package, but is more explicit about where exactly here() is.

The package supports many commonly used project types, allowing you to specify paths relative to various parts of your project. All path helpers prefixed with from_rproj(), allowing you to tab-complete the desired project root from one of these supported project roots:

Installation

To install the fromhere package from GitHub, use the remotes package:

# Install remotes if you don't have it yet
install.packages("remotes")

# Install fromhere from GitHub
remotes::install_github("mitchelloharawild/fromhere")

Usage

library(fromhere)

fromhere provides two main methods for generating file paths relative to the root of various project types:

  1. Using functions: from_rproj("path/to/file")

    Using strings to specify file paths, allowing a more programmatic approach to building paths.

  2. Using $ for autocompletion: from_rproj$path$to$file

    This method allows for a more interactive approach to specifying file paths, where the autocompletion is relative to the from_* folder.

Both methods produce the same result, and you should choose the method that best fits your needs.

File paths with functions

File paths can be specified using "strings" within the helper functions (much like here::here() and file.path()). You can use from_rproj("path/to/file") or pass multiple path components using from_rproj("path", "to", "file"). is more programmatic and provides flexibility for generating file paths.

The function will automatically generate the appropriate file path relative to the project root.

Examples:

File paths with $

This method is ideal for interactive usage and provides autocompletion support for easier navigation. Once you call the from_rproj function, you can use the $ operator to navigate deeper into the directory structure, which is particularly useful when working interactively in RStudio or other IDEs.

Examples:

File paths created using this package can be further navigated with $, for example:

rpkg <- from_r_package()
rpkg
#> [1] "/home/github/mitchelloharawild/fromhere"
rpkg$R$from.R
#> [1] "/home/github/mitchelloharawild/fromhere/R/from.R"