Temporarily Change Project Root

Lets you temporarily execute an expression or a local block with a different here() root in the 'here' package. This is useful for sourcing code in other projects which expect the root directory of here() to be the project directory of those projects. This may be the case with git submodules for example.


wither

R-CMD-check

Run a block or expression temporarily under a different here() root.

This is useful if you need to source R code from another project for example (as might be the case with git submodules)

Installation

You can install the development version of wither from GitHub with:

# install.packages("pak")
pak::pak("torbjorn/wither")

Example

with_here

with_here() evaluates an expression under a temporarily different here root():

library(here)
library(wither)

was <- here()

d <- tempfile()
dir.create(d)

# have here() be somewhere else for an expression
is_now <- with_here(d, here())

stopifnot(normalizePath(was) != normalizePath(is_now))

# clean up
unlink(d, recursive=TRUE)

local_here

local_here() evaluates the remainder of a block under a temporarily different here root():

library(here)
library(wither)

was <- here()

d <- tempfile()
dir.create(d)

local({

    # have here() be somewhere else for the rest of the block
    local_here(d)

    is_now <- here()

    stopifnot(normalizePath(was) != normalizePath(is_now))

})

# clean up
unlink(d, recursive=TRUE)

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("wither")

0.1.0 by Torbjørn Lindahl, 2 years ago


https://github.com/torbjorn/wither


Report a bug at https://github.com/torbjorn/wither/issues


Browse source code at https://github.com/cran/wither


Authors: Torbjørn Lindahl [aut, cre, cph] , Anja Minsaas [aut]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports fs, here, withr

Suggests devtools, testthat


See at CRAN