Skip to contents

is_run_directly() returns TRUE when you call it at the top level of the R console or of an Rscript file. It returns FALSE inside a function, and inside source(), eval() and a knitr chunk.

Usage

is_run_directly()

Value

TRUE or FALSE.

Details

Put it at the start of an action function to load data and argset while you develop the function line by line. When the plan runs the function, it returns FALSE, so the lines do nothing.

See also

vignette("plnr"), whose "Debugging" section shows the pattern.

Other plan helpers: Plan, expand_list(), get_anything(), set_opts()

Examples

f <- function() {
  is_run_directly()
}
f()
#> [1] FALSE