Yes, that is it. Thank you very much, Phil. -----Original Message----- From: Phil Spector [mailto:spec...@stat.berkeley.edu] Sent: Thursday, February 17, 2011 3:36 PM To: Jim Moon Cc: r-help@r-project.org Subject: Re: [R] sort by column and row names
Jim - I believe dat[order(rownames(dat)),order(colnames(dat))] is what you are looking for. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Thu, 17 Feb 2011, Jim Moon wrote: > Hello, All, > > How can one sort on column and row names. For example: > > How can this > X1 X3 X2 > X1 1 0 0 > X3 0 1 0 > X2 0 0 1 > > become this? > X1 X2 X3 > X1 1 0 0 > X2 0 1 0 > X3 0 0 1 > > > Thank you for your time! > > Jim > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.