Let's say I have a function like this:
myFun <- function(arg1, arg2, arg3) {
if(arg3 == 'A') funA(arg1, arg2)
else if(arg3 == 'B') funB(arg1, arg2)
else if(arg3 == 'C') funC(arg1, arg2)
}
Is there a way to not continually repeat arg1, arg2, but somehow construct the call more intelligently? I was looking into match.call but am not sure if it fits my use case.
myFun <- function(arg1, arg2, arg3) get(paste0("fun", arg3))(arg1, arg2)but I'm not sure whether your functions connect as in your example.