4 Accessing databases

Aside from static datasets, we often need to access data held in various kinds of SQL database in R.

Exporting data adds an unnecessary overhead, so it’s usually desirable to read data from the database directly. There are many ways to access databases from R using traditional SQL queries, but we’ll be focusing on using dbplyr, and by extension DBI, which allows us to use database tables with dplyr as if they were a standard data frame.