Message-ID: <8975119BCD0AC5419D61A9CF1A923E95030083E9@iahce2ksrv1.iah.bbsrc.ac.uk>
Date: 2006-02-24T14:07:19Z
From: michael watson (IAH-C)
Subject: Sorting a dataframe by one column?
You mean like this?
a<-1:10
b<-(a-5)^2
d<-data.frame(a,b)
d[order(d$b),]
??
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of mtb954 mtb954
Sent: 24 February 2006 13:55
To: r-help at stat.math.ethz.ch
Subject: [R] Sorting a dataframe by one column?
Given the following dataframe:
A=1:10
B=(a-5)^2
DATAFRAME=data.frame(A,B)
How can I sort DATAFRAME increasing (or decreasing, for that matter) by
B without making reference to A, or any other column?
I've read ?order and ?sort but cannot seem to figure this out.
Thank you.
Mark
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html