s-news
[Top] [All Lists]

Re: sorting dataframe on rownames

To: Jonathan Dakin <jdakin@overwey.demon.co.uk>
Subject: Re: sorting dataframe on rownames
From: Sundar Dorai-Raj <sundar.dorai-raj@pdf.com>
Date: Tue, 28 Mar 2006 10:38:06 -0800
Cc: Splus Mailing List <s-news@lists.biostat.wustl.edu>
In-reply-to: <000701c65297$12d9f0d0$1afea8c0@jdakin>
Organization: PDF Solutions, Inc.
References: <000701c65297$12d9f0d0$1afea8c0@jdakin>
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)


Jonathan Dakin wrote:
Could anyone tell me how to sort a dataframe alphabetically according to the rownames ? Sorry for the triviality. I could create a column equal to the rownames vector, sort on that and then remove the column, but it seems there should be a quicker way about.

Many thanks for any help.  (Using version 6.1).

Jonathan Dakin
Portsmouth Hospital




How about:

x[order(row.names(x)), ]

where 'x' is your data.frame.

--sundar

<Prev in Thread] Current Thread [Next in Thread>