/injectr

R package to inject code to existing functions

Primary LanguageROtherNOASSERTION

injectr

R package for injecting code into existing functions.

Usage

library(injectr)

Look for the documentation of the inject_code.

Examples

On entry example

f <- function(x) {
  x*x
}

inject_code(message("f called with x: ", x), f)

f(42)

## f called with x: 42

## [1] 1764

On exit example

f <- function(x) {
  x*x
}

inject_code(message("f called with x: ", x, " returning: ", returnValue()), f, "onexit")

f(42)

## f called with x: 42 returning: 1764

## [1] 1764

Building

make build