[R] SQL/R

Gildas Mazo gildas.mazo at curie.fr
Thu Jul 22 13:52:07 CEST 2010


Dear R users,

I want to aggregate data in the following way:

###

X <- data.frame(u = c("T1","T1","T1","T2"), v=c("a","a","b","a"))
X
library(sqldf)
sqlOut <- sqldf("select count(distinct(v)) from X group by u")
sqlOut

###

Now I want to get the same result without using SQL. How can I achieve
that ?

Thanks for your help,

Gildas



More information about the R-help mailing list