Let say I have the function
mean_wrapper <- function(x) {
mean(x)
}
How can I check if the mean
function is called?
You could trace mean
:
trace(mean, tracer = quote(message("mean was called")))
mean_wrapper(3)
#Tracing mean(x) on entry
#mean was called
#[1] 3
untrace(mean)
#Untracing function "mean" in package "base"
Instead of a message you can use anything (e.g., assignment to a variable in the enclosing environment) as tracer.