Re: [R] Simple order() data frame question.

2011-05-12 Thread John Kane
Dowle wrote: > From: Matthew Dowle > Subject: Re: [R] Simple order() data frame question. > To: r-h...@stat.math.ethz.ch > Received: Thursday, May 12, 2011, 11:23 AM > > With data.table, the following is routine : > > DT[order(a)]   # ascending > DT[order(-a)]  # desc

Re: [R] Simple order() data frame question.

2011-05-12 Thread Matthew Dowle
With data.table, the following is routine : DT[order(a)] # ascending DT[order(-a)] # descending, if a is numeric DT[a>5,sum(z),by=c][order(-V1)] # sum of z group by c, just where a>5, then show me the largest first DT[order(-a,b)] # order by a descending then by b ascending, if a and b are

Re: [R] Simple order() data frame question.

2011-05-12 Thread Ivan Calandra
I was wondering whether it would be possible to make a method for data.frame with sort(). I think it would be more intuitive than using the complex construction of df[order(df$a),] Is there any reason not to make it? Ivan Le 5/12/2011 15:40, Marc Schwartz a écrit : On May 12, 2011, at 8:09 AM

Re: [R] Simple order() data frame question.

2011-05-12 Thread Marc Schwartz
On May 12, 2011, at 8:09 AM, John Kane wrote: > Argh. I knew it was at least partly obvious. I never have been able to read > the order() help page and understand what it is saying. > > THanks very much. > > By the way, to me it is counter-intuitive that the the command is > >> df1[order(df1

Re: [R] Simple order() data frame question.

2011-05-12 Thread John Kane
it to be order( , df1[,2],decreasing=TRUE) So clearly I don't understand what is going on but at least I a lot better off. I may be able to get this graph to work. --- On Thu, 5/12/11, Patrick Breheny wrote: > From: Patrick Breheny > Subject: Re: [R] Simple order() data

Re: [R] Simple order() data frame question.

2011-05-12 Thread John Kane
Ah, this never would have occured to me. It's rather obvious now but of course, I'll forget it again. Note to self: Put it in the cribsheet. Thanks very mcuy --- On Thu, 5/12/11, Nick Sabbe wrote: > From: Nick Sabbe > Subject: RE: [R] Simple order() data frame question. &

Re: [R] Simple order() data frame question.

2011-05-12 Thread Nick Sabbe
Try (df1[order(-df1[,2]),]) Adding the minus within the [ leaves out the column (in this case column 2). See ?"[". HTH. Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove -Original Mess

Re: [R] Simple order() data frame question.

2011-05-12 Thread Patrick Breheny
On 05/12/2011 08:32 AM, John Kane wrote: Clearly, I don't understand what order() is doing and as ususl the help for order seems to only confuse me more. For some reason I just don't follow the examples there. I must be missing something about the data frame sort there but what? I originally