I am trying to capture the name of the input variable as a character string. This is fairly easy using match.call()
however this doesn't work when using magrittr's pipes. Wondering if there is any easy modification that would get it to work within pipes as well as if the function was called normally?
library(magrittr)
myfun <- function(fun){
print(match.call()$fun %>% as.character())
}
myfun(mean)
mean %>% myfun
myfun(iris)
iris %>% myfun