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,
PROTECTED] Behalf Of Marlin Keith Cox
Sent: February 19, 2008 2:07 PM
To: r-help@r-project.org
Subject: [R] addition of matrix
Thank you ahead of time for help with this.
I have two matrices
X
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 660 693.00 726.0 759.00 792.0 825.00
[2,] 548 575.40 602
Thank you ahead of time for help with this.
I have two matrices
X
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 660 693.00 726.0 759.00 792.0 825.00
[2,] 548 575.40 602.8 630.20 657.6 685.00
[3,] 676 709.80 743.6 777.40 811.2 845.00
[4,] 763 801.15 839.3 877.45 915.6 953.75
[5,] 768 80
3 matches
Mail list logo