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
below is another way ( maybe the same ? )but with an extra line to make roworder. i'm also not clear on why I have to take the transpose of the result that comes back form the apply call. in ?apply, it says that the function tries to convert the result back to a matrix. that's fine but why doe

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

2008-07-31 Thread Johnson, Eric A. (Seattle)
If you're not adverse to cbind-ing a1 and a2, 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,