Since ROracle package comes as a source code, its installation requires compilation. The installation is further complicated due to requiring Oracle client. Also, for Mac OS, fix_oralib.rb has been obsolete since Oracle Instant client 12.1 for OS X was released, we will get many errors related to loading dylib files from Oracle client:
- OCI Libraries not found
- Library not loaded: @rpath/libclntsh.dylib.12.1 Referenced from: /Library/Frameworks/R.frameworks/...
- Other errors with Xcode
There is no single correct instruction on how to get the package installed on latest Mac OS systems such as Yosemite and El Capitan. The following documents working instructions for both Windows and Mac OS.
Shortcut Procedure to Install ROracle for Windows (Updated on 9/8/2024)
If you want a customized installation, please follow the procedure below that I proposed on 6/21/2022. Otherwise, this is a much simpler procedure to install ROracle:
- Install the current version of R-core, such as R 4.4.
- Install R Studio from https://www.rstudio.com/products/rstudio/download/#download
- Install Rtools from https://cran.r-project.org/bin/windows/Rtools/ (make sure to download the version such as 4.4 that matches your R version, download the Windows Installer, and choose default settings during the installation)
- Install Oracle Instant Client: Download the oracle instant client, drag the folder named "instantclient" to your C drive
- Setup Environment Variables: Right mouse click on file named "environmentVars.bat" inside the instantclient folder and choose run it as Administrator (Note: this code is to create an environment variable called OCI_LIB64 and add a path variable to PATH so that they are pointing to c:\instantclient). This will change your registry items for required environment variables.
- Download the archive file ROracle.zip. Open the zip file and drag a file named "ROracle_1.4-1.tar.gz" to your desktop.
- Now open R and run the following three commands one by one and make sure you navigate to the desktop and choose ROracle_1.4-1.tar.gz to continue after the third command:
install.packages("DBI")
library(DBI)
install.packages(file.choose(), repos=NULL, type="source")
To test Oracle connection
Run the following two commands in R:
- library(ROracle)
- c.string="ism.uakron.edu:1521/cob19c.uanet.edu"
- con=dbConnect(Oracle(),username="scott",password="tiger",dbname=c.string)
- dbListTables(con)
Custom Installation of ROracle for Windows (Updated on 6/21/2022)
Follow this instruction if the above shortcut installation does not work for you. The installation for Windows is eventless, but make sure you follow the step carefully:
Install Oracle Instant Client
Install R and R Studio
- Install the current version of R-core, such as R 4.4. If you want to download an earlier version, go to https://cran.r-project.org/bin/windows/base/old/3.6.0/. Run the downloaded file to install.
- Install R Studio from https://www.rstudio.com/products/rstudio/download/#download
- Install Rtools from https://cran.r-project.org/bin/windows/Rtools/
Install ROracle
- Download ROracle_1.4-1.tar.gz (for R 4.0 version) from https://www.oracle.com/database/technologies/roracle-downloads.html (the file can be also found here on ecourse.org ROracle.zip)
- Open R or R Studio and run command: install.packages("DBI") and then load the package using command library(DBI)
- Run command: install.packages(file.choose(), repos=NULL, type="source") to choose the downloaded zip file to install.
- Run command: library(ROracle)
To test Oracle connection
Run the following two commands in R:
- c.string="ism.uakron.edu:1521/cob19c.uanet.edu"
- con=dbConnect(Oracle(),username="scott",password="tiger",dbname=c.string)
- dbListTables(con)
Customer ROracle for Mac OS (Updated on 6/21/2022)
Follow the instructions carefully. First you will need to get Oracle Instant Client successfully.
Prerequisite: install Xcode command line tools using the command in. terminal:
xcode-select –install
Install Oracle Instant Client: Follow this guide to install Oracle instant client for MacOS
Install ROracle
1. Open terminal and run the following commands to copy Oracle's library files
sudo cp /usr/local/oracle/instantclient/*.dylib.19.1 /usr/local/lib sudo cp /usr/local/oracle/instantclient/*.dylib /usr/local/lib
sudo cp /usr/local/oracle/instantclient/*.dylib.19.1 /Library/Frameworks/R.framework/Resources/lib sudo cp /usr/local/oracle/instantclient/*.dylib /Library/Frameworks/R.framework/Resources/lib
2. Download ROracle package file ROracle_1.3-1.1.tar.zip from https://cran.r-project.org/web/packages/ROracle/index.html and save it anywhere, say Downloads folder. You may also download it from ecourse.org.
3. Open R, and run command: install.packages("DBI")
4. Go back to terminal, run the following commands to install ROracle
sudo R CMD INSTALL --configure-args='--with-oci-lib=/usr/local/oracle/instantclient --with-oci-inc=/usr/local/oracle/instantclient/sdk/include' ~/Downloads/ROracle_1.3-1.1.tar
5. Now go to R and run command: library(ROracle)
|