SQL-like functionality in R
Asked Answered
W

2

13

I am used to writing data manipulation logic in SQL and now that I am learning R I find myself sometimes just wanting to do something that would be simple in SQL but I have to learn a bunch of stuff with R to do the same manipulation on an R data frame. Is there a simple work around?

Woodenware answered 23/7, 2009 at 4:4 Comment(1)
Can you give any examples please?Trapes
W
12

look at the package sqldf. http://code.google.com/p/sqldf/ It seems perfect for your needs.

Wardmote answered 23/7, 2009 at 4:26 Comment(0)
A
11

I'm also more comfortable with SQL, but when working with large data sets in R, my favourite manipulation tool is the data.table package. Unlike sqldf, which lets you write SQL in R, data.table lets you write R in R - but gives you the ability to add indexes on data frames (well, data.tables, to be precise). The ability to index data frames makes 'joins' much much much faster. And being an R implementation, your code still looks like R.

Acey answered 23/7, 2009 at 14:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.