Perhaps the most common external source of data is from relational databases. Since this section is probably of interest to only those who work with databases—or at least plan to—some knowledge of the basics of relational databases is assumed.
One way to connect to databases from R is to use the RODBC
package. This allows one to access any database that implements the ODBC common interface (for example, PostgreSQL, Access, Oracle, SQLite, DB2, and so on). A more common method, for whatever reason, is to use the DBI
package and DBI-compliant drivers.
DBI
is an R package that defines a generalized interface for communication between different databases and R. As with ODBC, it allows the same compliant SQL to run on multiple databases. The DBI
package alone is not sufficient for communicating with any particular database from R; in order to use DBI
, you must also install and load a DBI-compliant driver for your particular database. Packages exist providing drivers for many...