Yes, see mapply.
On Sat, Sep 5, 2009 at 12:18 PM, Peng Yu <[email protected]> wrote:
> 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
>
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.