Re: [R] by group problem

2007-09-04 Thread Cory Nissen
3:51 AM To: Cory Nissen Cc: r-help@stat.math.ethz.ch Subject: RE: [R] by group problem Hi now I understand better what you want topN.2 - function(data,n=5) data[order(data[,3], decreasing=T),][1:n] # I presume data is data frame with 3 columns and the third is percent lapply(split(data,data

Re: [R] by group problem

2007-09-03 Thread Petr PIKAL
Hi now I understand better what you want topN.2 - function(data,n=5) data[order(data[,3], decreasing=T),][1:n] # I presume data is data frame with 3 columns and the third is percent lapply(split(data,data$state), topN.2) Regards Petr [EMAIL PROTECTED] Cory Nissen [EMAIL PROTECTED] napsal

Re: [R] by group problem

2007-09-01 Thread Erich Neuwirth
Perhaps you want this? data - NULL data$state - c(rep(Illinois, 10), rep(Wisconsin, 10)) data$county - c(Adams, Brown, Bureau, Cass, Champaign, Christian, Coles, De Witt, Douglas, Edgar, Adams, Ashland, Barron, Bayfield, Buffalo, Burnett,

Re: [R] by group problem

2007-08-31 Thread Gabor Grothendieck
See the examples labelled head in the examples section near the bottom of: http://sqldf.googlecode.com/svn/trunk/man/sqldf.Rd These show show to do it using order as well as using SQL via sqldf. On 8/31/07, Cory Nissen [EMAIL PROTECTED] wrote: I am working with census data. My columns of

Re: [R] by group problem

2007-08-31 Thread Cory Nissen
That didn't work for me... Here's some data to help with a solution. data - NULL data$state - c(rep(Illinois, 10), rep(Wisconsin, 10)) data$county - c(Adams, Brown, Bureau, Cass, Champaign, Christian, Coles, De Witt, Douglas, Edgar, Adams, Ashland, Barron,

Re: [R] by group problem

2007-08-31 Thread Henrique Dallazuanna
Hi, try this: by(data$percentOld, list(data$state, data$county), FUN=topN) is this you want? -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O On 31/08/2007, Cory Nissen [EMAIL PROTECTED] wrote: That didn't work for me... Here's some data to help with a solution.