This is a problem much like the one I had a few weeks ago. David's solution is more concise. Try xtfrm() or rank() for factor sorting
d=data[order(data$ID,-xtfrm(data$Type)),] should work. By the way I got it from Duncan. Jun On Fri, May 8, 2009 at 4:09 PM, David Freedman <3.14da...@gmail.com> wrote: > > sorry about the mistake - the -data$Type doesn't work: the '-' sign isn't > valid for factors. I *thought* I had checked this before submitting a > response ! > > > HufferD wrote: > > > > On Thursday, May 07, 2009 7:45 PM, David Freedman wrote: > > > > > ...how about: > > > d=data[order(data$ID,-data$Type),] > > > d[!duplicated(d$ID),] > > > > Does the "-data$Type" argument to the order function work? > > > > -- > > David > > > > ----------------------------------------------------- > > David Huffer, Ph.D. Senior Statistician > > CSOSA/Washington, DC david.huf...@csosa.gov > > > > ______________________________________________ > > 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. > > > > > > -- > View this message in context: > http://www.nabble.com/by-group-processing-tp23417208p23453688.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. > -- Jun Shen PhD PK/PD Scientist BioPharma Services Millipore Corporation 15 Research Park Dr. St Charles, MO 63304 Direct: 636-720-1589 [[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.