Re: [R] addition of matrix

2008-02-19 Thread Gabor Grothendieck
This is your original problem: f <- function(x, y) as.vector(outer(x, y, "/")) mapply(f, as.data.frame(t(X)), as.data.frame(t(Y))) so just replace "/" with whatever function of two variables you like. See ?outer and be sure your function replacing "/" is vectorizable as noted there. On Feb 19,

Re: [R] addition of matrix

2008-02-19 Thread Yinghai Deng
Hello Keith, Based on what you have done, please try this: M<-matrix(nrow=num.rows, ncol=num.x.col*num.y.col) for( i in 1:num.rows){M[i,]<-rep(Y[i,], each=num.y.col)} Z<-Z+M not elegant, but works. HTH YH Deng -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Beha