May 28, 2016

How to install ROracle in Windows 7

  1. Download binary from oracle

  2. Run the following command in r, substituting the file path:

    setwd('PATH TO DOWNLOAD')   # set to path of download (remember to escape slashes ie:  c:\\users\\etc..)
    install.packages('ROracle_1.2-1.zip', repos = NULL)
    
  3. Then load the library and use the package - you will have to change MYDB to a valid connection from your tnsnames.ora file.

    library('ROracle')
    drv <- dbDriver("Oracle")
       
    # NOTE: never store passwords in a saved script!!
    con <- dbConnect(drv, "USER GOES HERE", "PASSWORD GOES HERE", dbname='XXX')
       
    # test connection:
    dbReadTable(con, 'DUAL')
    
  4. If all goes to plan, the last command shoud return a dataframe with a single value of ‘X’.

Now that the basics are working, check out my post on how to securely pass encrypted passwords to R scripts in Windows.