How to write tidy SQL queries in R
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…