Re: [R] Ordering data.frame based on class

2011-03-28 Thread Vincy Pyne
Dear sir, Thanks for the great solution. Regards Vincy --- On Mon, 3/28/11, Henrique Dallazuanna wrote: From: Henrique Dallazuanna Subject: Re: [R] Ordering data.frame based on class To: "Vincy Pyne" Cc: r-help@r-project.org Received: Monday, March 28, 2011, 9:02 PM Try thi

Re: [R] Ordering data.frame based on class

2011-03-28 Thread Henrique Dallazuanna
Try this: my_dat[order(my_dat$class, -my_dat$var1, decreasing = TRUE),] On Mon, Mar 28, 2011 at 5:55 PM, Vincy Pyne wrote: > Dear R helpers > > Suppose I have a data.frame as given below - > > my_dat = data.frame(class = c("XYZ", "XYZ", "XYZ", "XYZ", "XYZ","ABC", "ABC", > "ABC", "ABC", "ABC" ),

[R] Ordering data.frame based on class

2011-03-28 Thread Vincy Pyne
Dear R helpers Suppose I have a data.frame as given below - my_dat = data.frame(class = c("XYZ", "XYZ", "XYZ", "XYZ", "XYZ","ABC", "ABC", "ABC", "ABC", "ABC" ),  var1 = c(20, 14, 89, 81, 17, 44, 36, 41, 11, 36), var2 = c(1001, 250, 456, 740, 380, 641, 111, 209, 830, 920)) > my_dat    class var