[R] SQL like manipulations on data frames

Robert Citek rwcitek at alum.calberkeley.org
Fri May 5 00:56:08 CEST 2006


Is there a cheat-sheet anywhere that describes how to do SQL-like  
manipulations on a data frame?

My knowledge of R is rather limited.  But from my experience it seems  
as though one can think of data frames as being similar to tables in  
a database: there are rows, columns, and values.  Also, one can  
perform similar manipulations on a data frame as one can on a table.   
For example:

  select * from foo where bar < 10 ;

is similar to

  foo[foo["bar"] < 10,]

I'm just wondering how many other SQL-like manipulations can be done  
on a data frame?  As an extreme example, is it reasonable to assume  
there is an R equivalent to:

select bar, bat, baz, baz*100 as 'pctbaz' from foo where bar like %xyz 
% order by bat, baz desc ;

Regards,
- Robert
http://www.cwelug.org/downloads
Help others get OpenSource software.  Distribute FLOSS
for Windows, Linux, *BSD, and MacOS X with BitTorrent




More information about the R-help mailing list