Re: [R] Doing SQL GROUP BY in R
JFRI (Jesper Frickmann) wrote: I want a list of the number of times some factor levels appear together, Say a and b are the names of the factors: table(a,b) table(a:b) aggregate(a,list(a=a,b=b),length) Christophe Pallier http://www.pallier.org __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Doing SQL GROUP BY in R
I want a list of the number of times some factor levels appear together, similar to the following SQL statement: SELECT A, B, COUNT(C) FROM TBL GROUP BY A, B How do I do that with a data.frame in R? Thanks, Jesper Frickmann Statistician, Quality Control Novozymes North America Inc. 77 Perry Chapel Church Road Franklinton, NC 27525 USA Tel. +1 919 494 3266 [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Doing SQL GROUP BY in R
You might want to look at ?table and ?xtab. See also ?tapply for use of general functions (other than just COUNT) with GROUP BY. HTH, Vadim -Original Message- From: JFRI (Jesper Frickmann) [mailto:[EMAIL PROTECTED] Sent: Friday, April 02, 2004 1:06 PM To: [EMAIL PROTECTED] Subject: [R] Doing SQL GROUP BY in R I want a list of the number of times some factor levels appear together, similar to the following SQL statement: SELECT A, B, COUNT(C) FROM TBL GROUP BY A, B How do I do that with a data.frame in R? Thanks, Jesper Frickmann Statistician, Quality Control Novozymes North America Inc. 77 Perry Chapel Church Road Franklinton, NC 27525 USA Tel. +1 919 494 3266 [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo /r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Doing SQL GROUP BY in R
Assuming you have a data.frame, dat, with coluns A and B, I think what you want would be: table(paste(dat$A,dat$B)) JFRI (Jesper Frickmann) wrote: I want a list of the number of times some factor levels appear together, similar to the following SQL statement: SELECT A, B, COUNT(C) FROM TBL GROUP BY A, B How do I do that with a data.frame in R? Thanks, Jesper Frickmann Statistician, Quality Control Novozymes North America Inc. 77 Perry Chapel Church Road Franklinton, NC 27525 USA Tel. +1 919 494 3266 [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- - Pierre Kleiber, Ph.D Email: [EMAIL PROTECTED] Fishery Biologist Tel: 808 983-5399/737-7544 NOAA FISHERIES - Honolulu Laboratory Fax: 808 983-2902 2570 Dole St., Honolulu, HI 96822-2396 - God could have told Moses about galaxies and mitochondria and all. But behold... It was good enough for government work. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html