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
You mean like this?
a-1:10
b-(a-5)^2
d-data.frame(a,b)
d[order(d$b),]
??
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of mtb954 mtb954
Sent: 24 February 2006 13:55
To: r-help@stat.math.ethz.ch
Subject: [R] Sorting a dataframe by one column?
Given
mtb954 mtb954 wrote:
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.
Why won't order solve your problem? ?order in R 1.7.1 for Windows
includes an example sorting lexicographically 3 variables in ascending
order.
spencer graves
Paul, David A wrote:
Undoubtedly a simple question:
I've looked at order() and sort() in the help pages for
R1.7.1. It doesn't
Undoubtedly a simple question:
I've looked at order() and sort() in the help pages for
R1.7.1. It doesn't appear that these functions are immediately
suited to doing the same thing as
PROC SORT DATA = BLAH;
BY X Y Z;
RUN;
in SAS. I have also checked Frank Harrell's Hmisc library.
:[EMAIL PROTECTED]
Sent: 12 August 2003 17:39
To: '[EMAIL PROTECTED]'
Subject: [R] Sorting a dataframe
Undoubtedly a simple question:
I've looked at order() and sort() in the help pages for
R1.7.1. It doesn't appear that these functions are immediately
suited to doing the same thing
On Tue, 2003-08-12 at 11:38, Paul, David A wrote:
Undoubtedly a simple question:
I've looked at order() and sort() in the help pages for
R1.7.1. It doesn't appear that these functions are immediately
suited to doing the same thing as
PROC SORT DATA = BLAH;
BY X Y Z;
RUN;
in