This is a follow-up question to a question I posed earlier (Evaluating a function pointed to by a string in R) to make the problem and solution both more generic. Suppose I have the following:
x <- 1:3
y <- 2
foo <- function(x, y) {x^y}
a <- "foo"
b <- "x"
c <- "y"
I want to be able to evaluate the function foo using the strings defined by a, b, and c. Something like match.fun(a)(b, c), which I know is wrong, but will return
[1] 1 4 9
Or to make the question even more general, suppose
x <- 1:3
y <- 2
foo <- function(x, y) {x^y}
a <- "foo"
b <- "x, y"
How might match.fun be used to provide the same solution?
Any help is appreciated.