This is a question regarding coding in R.
The example I provide is didactic. Suppose I have functions called 'func1' and 'func2', where each takes two arguments (let's say scalars). I want to specify another function 'applyfunction' that has three args: the last number of the function to use ('1' or '2'), and the two arguments for the function. For example, I want to do something like this (which of course doesn't work):
applyfunction(1,2,3)
where it would effectively run func1(2,3)
and
applyfunction(2,9,43)
where it would effectively run func2(9,43)
.
Any ideas?
Best, DB
match.fun
is slightly preferable toget
for this use. – Creosote