In R, I have a function which takes the name of another function as a parameter. I’ve constructed an if-statement within the parent function to check if the input function name is the same as the name of an already existing function of the name strategy_function.
function_parent <- function(function_name){
if(function_name == strategy_function){...}
}
However, R does not appreciate this notation. Is using the name of a function in this way possible, and even if it is, is there a better way? This seems slightly sloppy.
Using
deparse(substitute(strategy_function))in the comparison did the trick.