[R] ordering columns in a data frame

2010-03-10 Thread Newbie19_02
Dear R users, I have the following data frame: PROCHIdate_admission 2 CAO713 1999-12-11 4 CAO713 1999-10-25 21 CAO0001743 1989-05-04 25 CAO0001743 1996-09-12 26 CAO0001743 1989-05-17 27 CAO0001743 1987-09-17 28 CAO0001743 1987-09-19

Re: [R] ordering columns in a data frame

2010-03-10 Thread David Freedman
I'm not sure what's incorrect about your result, but the following works: d=data.frame(a=sample(letters[1:5],10,rep=T),b=rnorm(10),c=sample(1:10,10)); d d[order(d$a,d$c),] or, you can use orderBy: lib(doBy) orderBy(~a+b,data=d) #use a - sign to sort in descending sequence Did you leave off the

Re: [R] ordering columns in a data frame

2010-03-10 Thread Newbie19_02
Thanks David. Leaving off the tilde was the problem. -- View this message in context: http://n4.nabble.com/ordering-columns-in-a-data-frame-tp1587294p1587491.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org