If I want to get the name of a function (as a string) I can do this:
as.character(quote(mean))
#> [1] "mean"
Or this:
as.character(substitute(mean))
#> [1] "mean"
However this doesn't work if I try to get the function name inside another function.
e.g.
print_fun <- function (fun) {
function_name <- as.character(quote(fun))
print(function_name)
}
print_fun(mean)
#> [1] "fun"
What I am doing wrong?