Skip to content

order matrix by column position

3 messages · Gabor Grothendieck, Folkes, Michael

#
On Thu, Dec 9, 2010 at 5:24 PM, Folkes, Michael
<Michael.Folkes at dfo-mpo.gc.ca> wrote:
Try this:

ix <- 1:3
results[do.call(order, as.data.frame(results)[ix]), ]

as.data.frame can optionally be omitted if the results object is
already a data frame (in your example code its a matrix).