R package for injecting code into existing functions.
library(injectr)
Look for the documentation of the inject_code
.
f <- function(x) {
x*x
}
inject_code(message("f called with x: ", x), f)
f(42)
## f called with x: 42
## [1] 1764
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
make build