On Sat, 2007-10-20 at 18:15 +0700, Sandra Stattman wrote: > Hi, I am writing my B.SC thesis and I have to do something in R, my data are > > i index id x > 1 1 1 0.2 > 2 2 1 0.4 > 3 3 1 0.3 > 4 1 2 0.5 > 5 2 2 0.3 > 6 3 2 0.1 > 7 1 3 0.2 > 8 2 3 0.1 > 9 3 3 0.4 > > and for the analysis they have to be as > > i index id x > 1 1 1 0.2 > 4 1 2 0.5 > 7 1 3 0.2 > 2 2 1 0.4 > 5 2 2 0.3 > 8 2 3 0.1 > 3 3 1 0.3 > 6 3 2 0.1 > 9 3 3 0.4 > > Thank you for your help!
?order > dat i index id x 1 1 1 1 0.2 2 2 2 1 0.4 3 3 3 1 0.3 4 4 1 2 0.5 5 5 2 2 0.3 6 6 3 2 0.1 7 7 1 3 0.2 8 8 2 3 0.1 9 9 3 3 0.4 > ord <- order(dat$index, dat$id) > dat[ord, ] i index id x 1 1 1 1 0.2 4 4 1 2 0.5 7 7 1 3 0.2 2 2 2 1 0.4 5 5 2 2 0.3 8 8 2 3 0.1 3 3 3 1 0.3 6 6 3 2 0.1 9 9 3 3 0.4 HTH G > Sandra -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% ______________________________________________ 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.