How to write tidy SQL queries in R

Keith McNulty
Towards Data Science
3 min readOct 6, 2018

--

Most of us have to interact with databases nowadays, and SQL is by far the most common language used. However, working with SQL in R can be messy. If your queries are complex, you have to code them up as text strings which can be error prone, and suffer from formatting challenges. Also, when you want to build your SQL queries to have variables inside them, then you are forced to do substitution or pasting, which is a little bit hacky.

Ideally you want to be able to work with your database using tidy principles, taking advantage of the wonders of the tidyverse, and…

--

--

Pure and Applied Mathematician. LinkedIn Top Voice in Tech. Expert and Author in Data Science and Statistics. Find me on LinkedIn, Twitter or keithmcnulty.org