Extracts the details of a function as either it's name, or (if anonymous), some minimal details about it.
get_function_string(f)
f | function to be coerced to string |
---|
f <- function(x) x + 1 get_function_string(f)#> [1] "f"get_function_string( function(x) x + 1 )#> [1] "x + 1"#> [1] "mean(1:10)"get_function_string( function(x) stats::mean(1:10) )#> [1] "stats::mean(1:10)"get_function_string( function(x) (x + 1) )#> [1] "(x + 1)"get_function_string( function(x) (3 * x + 1) / 2 )#> [1] "(3 * x + 1)/2"get_function_string( function(x) { x + 2 } )#> [1] "{ x + 2 }"get_function_string( function(x) { y <- x + 2 x + y } )#> [1] "{ y <- x + 2; x + y }"get_function_string( function(x) { y <- x + 2 x + y y^2 } )#> [1] "{ y <- x + 2; ... }"