If your data are stored in a database, it is possible to directly access the database through R. This can be done using Open Database Connectivity (ODBC) through the package RODBC. Note that before using ODBC, you should make sure it is correctly set up on your computer (under Control Panel/Administrative Tools in Windows). Then, you’ll need to install the RODBC package in R:
Finally, you will be able to connect to your database, run SQL queries to download the data in R as data frames, and close the connection as follows: