I have a function with 4 arguments:
my.function <- function(w,x,y,z){
w + x + y + z
}
I can give this function multiple values for z:
> my.function(1,1,1,1:5)
[1] 4 5 6 7 8
But what if I want to give the function lists of values for w,x,y and a vector of values for z, such that the function will evaluate each set of wxy.args with each element of z?
wxy.args <- list(set1 = list(w = 1.1, x = 2.1, y = 3.1),
set2 = list(w = 1.2, x = 2.2, y = 3.3),
set3 = list(w = 1.3, x = 2.3, y = 3.3))
z <- 1:5
Ideally, I would like to end up with a n x m matrix, where n = set and m = z. For that reason, I wanted to use outer(), but it doesn't seem like that is possible.
So, I guess this will involve one of the apply family or some combination of apply and do.call, but I'm struggling with it.
Thanks in advance!