Learn R Programming

this.path (version 2.5.0)

Enhances: Functions That Enhance the Use of Other Packages

Description

These functions improve the user experience of other packages.

Usage

## enchances 'package:box'
with_script_path(expr, local = FALSE, n = 0, envir = parent.frame(n + 1),
    matchThisEnv = getOption("topLevelEnvironment"),
    srcfile = if (n) sys.parent(n) else 0)

## enchances 'package:rprojroot' make_fix_file(criterion, local = FALSE, n = 0, envir = parent.frame(n + 1), matchThisEnv = getOption("topLevelEnvironment"), srcfile = if (n) sys.parent(n) else 0)

Value

for with_script_path(), the result of evaluating expr.

for make_fix_file(), a function with formals (..., .. = 0) that returns a character vector.

Arguments

expr

an expression to evaluate after setting the current script in package:box; most commonly a call to box::use().

criterion

argument passed to rprojroot::find_root().

local, n, envir, matchThisEnv, srcfile

See ?this.path().

Details

with_script_path() improves the experience of package:box; it sets the current script in package:box to this.path() using box::set_script_path(), then evaluates its argument, most commonly a package:box import statement.

make_fix_file() improves the experience of package:rprojroot; it looks for a project root starting with this.dir(), then makes a function that constructs file paths against said project root.

Examples

Run this code
# this.path::with_script_path(
# box::use(
#     ,
#     ,
#     <...>
# )
# )


# ## replace 'rprojroot::is_r_package' with desired criterion
#
# fix_file <- this.path::make_fix_file(rprojroot::is_r_package)

Run the code above in your browser using DataLab