In many circumstances, you might want to connect R directly to a database to store and retrieve data. If the source database is an Oracle database, you have a number of options:
Using ROracle should theoretically provide you with the best performing client, as this library is a wrapper around the Oracle OCI driver. The OCI driver, however, is platform-specific and requires you to install Oracle database client software.
What if you don’t want to write code that is either platform-specific or requires relatively complex, platform-specific installation steps? In this case, you should consider using RJDBC.
I’ll assume that you have a JRE/JDK installed and know the path to your JAVA_HOME.
- Hostname or IP, e.g., database.company.com
- Port, e.g., 1521
- Service name or SID, e.g., ORCL
This information will allow us to construct the DSN, which will look something like this: jdbc:oracle:thin:@//hostname:port/service_name_or_sid
Armed with this DSN and your Java home, you should now be able to modify and execute the example below.