[R] query in R

Mark Wardle mark at wardle.org
Wed Nov 8 13:16:45 CET 2006


Xiaodong Jin wrote:
> how to realize the following SQL command in R?
>    
>   select distinct A, B, count(C)
>   from TABLE
>   group by A, B
>   ;
>   quit;
>    
>   Best Regards

You don't say which database you are using, but I have found RODBC to be
very effective.

library("RODBC")

Have a look at odbcConnect(), and sqlQuery(). It is quite
straightforward; even I managed to use it!

Otherwise try help.search("sql") which provides links to many other,
database-specific packages.


Mark


-- 
Dr. Mark Wardle
Clinical research fellow and Specialist Registrar in Neurology,
C2-B2 link, Cardiff University, Heath Park, CARDIFF, CF14 4XN. UK



More information about the R-help mailing list