[R] R equivalent for SQL query

Steven Raemaekers s.raemaekers at sig.eu
Tue Apr 3 20:26:31 CEST 2012


Hi,

I have a query which I would like to translate into R, but I do not know how to do it in an easy way.
Assume a data frame has columns A, B and C:

A	B	C
1	1	3
1	1	4
1	1	5
1	2	6
1	2	7
1	3	8

The query is as follows: 

select A, B, count(*)
from data.frame
group by A, B
order by count(*) desc

How do I translate this into R statements in such way that the result is a data frame structured as follows: 

A	B	count(*)
1	1	3
1	2	2
1	3	1

Thanks,

Steven


More information about the R-help mailing list