[R] How to 'apply' on multiple arguments?
Peng Yu
pengyu.ut at gmail.com
Sat Sep 5 17:18:00 CEST 2009
Hi,
I am wonder if there is a function similar 'apply' but it could accept
multiple arguments?
For example, I have the following matrix.
x=matrix(1:6,nr=2)
y=matrix(1:6,nr=2)
I want to find a function that can be used to compute the linear
regression for each pair of rows in the two matrices?
multiple_apply(x,y,1,function(u,v){lm(u ~ v)}
That is, I wound like something like the above to compute the
following. Can somebody let me know if there is such an command in R?
lm(x[1,]~y[1,])
lm(x[2,]~y[2,])
Regards,
Peng
More information about the R-help
mailing list