Skip to content
Prev 144814 / 398500 Next

how can i sort a column of data.frame ?

? order

df<-data.frame(a=rnorm(20),b=rpois(20,5),c=runif(20))
or<-order(df$b,decreasing=T)
df.or<-df[or,]

Weidong Gu
Department of Medicine
University of Alabama, Birmingham
1900 University Blvd., Birmingham, Alabama 35294

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of hanen
Sent: Monday, May 19, 2008 1:11 PM
To: r-help at r-project.org
Subject: [R] how can i sort a column of data.frame ?


i have a data.frame with several columns that i want to sort one of them
(one
column) by descending order
 in such way that this sorting out  recover all colums. what should i
do?