Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

inject_funs

Inject functions into the environment of evaluate()


Description

Create functions in the environment specified in the envir argument of evaluate(). This can be helpful if you want to substitute certain functions when evaluating the code. To make sure it does not wipe out existing functions in the environment, only functions that do not exist in the environment are injected.

Usage

inject_funs(...)

Arguments

...

Named arguments of functions. If empty, previously injected functions will be emptied.

Note

For expert use only. Do not use it unless you clearly understand it.

Examples

library(evaluate)
# normally you cannot capture the output of system
evaluate("system('R --version')")

# replace the system() function
inject_funs(system = function(...) cat(base::system(..., intern = TRUE), sep = "\n"))

evaluate("system('R --version')")

inject_funs()  # empty previously injected functions

evaluate

Parsing and Evaluation Tools that Provide More Details than the Default

v0.14
MIT + file LICENSE
Authors
Hadley Wickham [aut], Yihui Xie [aut, cre] (<https://orcid.org/0000-0003-0645-5666>), Michael Lawrence [ctb], Thomas Kluyver [ctb], Jeroen Ooms [ctb], Barret Schloerke [ctb], Adam Ryczkowski [ctb], Hiroaki Yutani [ctb], Michel Lang [ctb], Karolis Koncevičius [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.