User Tools

Site Tools


documentation:r_setup

How to set up your R environment

Many of the OHDSI tools need to be executed from within R, and it is not always that easy to configure it correctly. Below are our recommendations for various use cases.

Tool users

Here are instructions for when you just want to run the OHDSI tools.

Windows

  1. Install R, which you can download from CRAN. Important: it is best to install R in the root of your drive, so preferably in c:/R/R-3.x.x
  2. Make sure Rtools is installed. We also recommend installing Rtools in the root, so in c:/Rtools
  3. Add the following environment variables (read this if you don't know how):
    • R_HOME with the location of R (e.g. c:/R/R-3.1.3)
    • HOME with the location of your home folder (e.g. c:/users/john)
    • R_LIBRARY with the location of your R library (e.g. c:/users/john/R/win-library/3.1)
  4. We found it is best to restart your computer for the environmental variables to take effect.
  5. Several OHDSI packages require Java, so please install that as well. On a 64-bit machine it is better to install the JDK rather than the JRE, since the JRE only seems to include the 32-bit version. If you have further trouble, be sure on Windows that your Path variable includes the path to jvm.dll (Windows Button –> type “path” –> Edit Environmental Variables –> Edit PATH variable, add to end ;C:/Program Files/Java/jre/bin/server) or wherever it is on your system.
  1. additional user notes (2016-07-06, Vojtech Huser). After many attempts to resolve the jml.dll issue, I was able to solve the error by forcing R to not try to install the package for all architectures. If all is failing, try adding install opts like this install.packages(“SqlRender”,INSTALL_opts=“–no-multiarch”)

Ubuntu

Install Java

First, we completely remove openjdk if present:

sudo apt-get purge openjdk-\*

Next we install Oracle Java:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

Install Git

sudo apt-get install git-all

Install R

sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list'
sudo gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
sudo gpg -a --export E084DAB9 | sudo apt-key add -
sudo apt-get update
sudo apt-get install r-base
sudo R CMD javareconf

If you're having trouble finding libjvm.so in R:

sudo updatedb
locate libjvm.so
sudo ln -s  /usr/lib/jvm/java-8-oracle/jre/lib/amd64/server/libjvm.so /usr/lib/ 

(adapt last line to correct location for your JRE)

Install required Linux packages

These libraries are required by some packages in R:

sudo apt-get install libcurl4-openssl-dev
sudo apt-get install libssl-dev
sudo apt-get install libxml2-dev
sudo apt-get install liblzma-dev

Tool developers

Here are instructions for when you want to develop OHDSI tools yourself.

(Still need to write this)

documentation/r_setup.txt · Last modified: 2016/07/06 21:37 by vojtechhuser