[R] Multi matrix row-wise mapply?
csardi.gabor at gmail.com
Tue Oct 21 11:49:11 CEST 2008
A relatively simple solutions is
sapply(seq(length=nrow(A)), function(x) f(A[x,], B[x,]))
but I'm looking forward to see anything cleaner/simpler,
On Tue, Oct 21, 2008 at 8:58 AM, cmr.Pent at gmail.com <cmr.Pent at gmail.com> wrote:
> Hi group!
> Suppose I have 2 matrices A and B of equal dimensions.
> I want to apply a function f to all corresponding pairs of rows from A
> and B in an efficient manner.
> Basically, I want
> mapply(f, data.frame(A), data.frame(B))
> but for rows.
> How do I do it?
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Gabor Csardi <Gabor.Csardi at unil.ch> UNIL DGM
More information about the R-help