try this:
d <- data.frame(RUN = rep(1:3, each = 3), ID = 1:9, AUC =
runif(9,1,100))
d[order(d$RUN, d$AUC), ]
I hope it helps.
Best,
Dimitris
Riley, Steve wrote:
Greetings!
I am trying to figure out how to order a data frame by one variable
conditioned on another.
Here is an example of what I have:
d <- data.frame(RUN = rep(1:3, each = 3), ID = 1:9, AUC =
runif(9,1,100))
d
RUN ID AUC
1 1 70.2
1 2 86.5
1 3 20.1
2 4 74.3
2 5 53.6
2 6 67.6
3 7 99.9
3 8 47.3
3 9 41.3
Here is what I want (data frame sorted by AUC within RUN):
d
RUN ID AUC
1 3 20.1
1 1 70.2
1 2 86.5
2 5 53.6
2 6 67.6
2 4 74.3
3 9 41.3
3 8 47.3
3 7 99.9
Here is my version info:
version
_
platform i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status
major 2
minor 7.2
year 2008
month 08
day 25
svn rev 46428
language R
version.string R version 2.7.2 (2008-08-25)
Any thoughts you could provide would be greatly appreciated. Thanks and
have a great day!
Steve
Steve Riley, Pharm.D., Ph.D.
Clinical Pharmacology, Specialty Neuroscience
Pfizer Specialty Care Business Unit
Mail Stop MS 6025-B2110
50 Pequot Ave
New London, CT 06320
steve.ri...@pfizer.com
Tel: (860) 732-1796
Fax: (860) 686-5672
[[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.
--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center
Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
______________________________________________
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.