Re: [R] sort rows of matrix by rows of another matrix

2008-07-31 Thread Steven McKinney
s." would be useful examples and comments for R's apply() help page. HTH Steve McKinney -Original Message- From: [EMAIL PROTECTED] on behalf of [EMAIL PROTECTED] Sent: Thu 7/31/2008 3:34 PM To: Johnson, Eric A. (Seattle) Cc: r-help@r-project.org Subject: Re: [R] sort rows of

Re: [R] sort rows of matrix by rows of another matrix

2008-07-31 Thread markleeds
you can use this: a1a2 <- cbind(a1, a2) a3 <- t(apply(a1a2, 1, function(x) x[order(x[1:ncol(a1)])+ncol(a1)])) Eric -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Timothy W. Hilton Sent: Thursday, July 31, 2008 2:19 PM To: r-help@r-project.o

Re: [R] sort rows of matrix by rows of another matrix

2008-07-31 Thread Johnson, Eric A. (Seattle)
ay, July 31, 2008 2:19 PM To: r-help@r-project.org Subject: [R] sort rows of matrix by rows of another matrix Hello all, I am trying to sort rows of one matrix by rows of another. Given a1 and a2: -- > a1 [,1] [,2] [,3] [1,]768 [2,]424 [3,]472 [4,]

[R] sort rows of matrix by rows of another matrix

2008-07-31 Thread Timothy W. Hilton
Hello all, I am trying to sort rows of one matrix by rows of another. Given a1 and a2: -- > a1 [,1] [,2] [,3] [1,]768 [2,]424 [3,]472 [4,]038 a1 <- structure(c(7, 4, 4, 0, 6, 2, 7, 3, 8, 4, 2, 8), .Dim = c(4L, 3L)) > a2 [,1] [,2] [,