Dear all, as per my understanding, outer() function is to facilitate
2-dimensional function evaluation, like to evaluate f(x,y) for different
values of x and y. However I have slightly modified version of that, where x
is a matrix with, say, 5 rows and 2 columns and y is a vector. Let take
following example:

 

fn1 <- function(x1, x2, y) return (x1+x2+y)

 

x <- matrix(1:10, nc = 2)

y <- 1:5

 

with this input, I want to construct a 5x5 matrix whose (1,1)th element will
be : fn1(x[1,1], x[1,2], y[1]), (1,2)th element will be : fn1(x[1,1],
x[1,2], y[2])..... (1,5)th element will be : fn1(x[1,1], x[1,2],
y[5]).....similarly (2,1)th element will be : fn1(x[2,1], x[2,2],
y[1])....etc

 

If my 'x' object is a vector then I can easily use outer() function
effectively. However for my present case, I am looking for some ***outer()
like function*** to get the result effectively. Can somebody help me on how
can I do that without using any for loop?

 

Thanks and regards,

 


	[[alternative HTML version deleted]]

