search for: multiple_apply

Displaying 1 result from an estimated 1 matches for "multiple_apply".

2009 Sep 05
2
How to 'apply' on multiple arguments?
...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