Here are the steps for installing the required environment to run the OHDSI R packages. Four things needs to be installed:
In order to install HADES, you must also set a GitHub Personal Access Token as described in this section
These instructions are also demonstrated in this video, showing a step-by-step guide to installing the required software.
Go to https://cran.r-project.org/bin/windows/base/old/4.2.3/, click on ‘R-4.2.3-win.exe’ to download.
After the download has completed, run the installer. Use the default options everywhere, with two exceptions: First, it is better not to install into program files. Instead, just make R a subfolder of your C drive as shown below. Second, to avoid problems due to differing architectures between R and Java, if you’re installing an older R version (< 4.2.0), disable the 32-bit architecture as also shown below.
Once completed, you should be able to select R from your Start Menu.
Go to https://cran.r-project.org/bin/windows/Rtools/rtools42/rtools.html, and download the RTools installer.
After downloading has completed run the installer. Select the default options everywhere.
Go to https://posit.co/download/rstudio-desktop/, select ‘Download RStudio Desktop For Windows’.
After downloading, start the installer, and use the default options everywhere.
Go to https://java.com/en/download/manual.jsp, and select the Windows 64-bit installer as highlighted below. If you also installed the 32-bit version of R, you must also install the other (32-bit) version of Java.
After downloading just run the installer.
Go to https://cran.r-project.org/bin/macosx/base/, click on ‘R-4.2.3.pkg’ to download.
After the download has completed, run the installer and accept all of the default options. You should see a screen indicating that the installation was successful.
We will need to install C and Fortran compilers in order to build R packages from source code. These are included with Xcode which can be downloaded from the Mac App store.
Open the App Store in Mac OS and install Xcode. Xcode is a large
program. If disk space is scarce you could also try only installing
Xcode command line tools by following the instructions here.
Verify that the C compiler gcc is installed by opening the terminal and
running the command
clang. You should see an error that
says “no input files”.
Download and install the gfortran compiler .dmg from https://github.com/fxcoudert/gfortran-for-macOS/releases.
Choose the latest version that is compatible with your operating system.
Verify the installation by opening the terminal and running the command
gfortran. You should see an error that says “no input
Go to https://www.xquartz.org/, download the .dmg and run the installer.
Verify that build tools are installed and available by opening an R console and running
Go to https://www.oracle.com/java/technologies/javase-jdk15-downloads.html, and select the Mac OS installer for the Oracle JDK as highlighted below.
After downloading just run the installer. Check that java is
installed by opening the terminal and running the command
java. If you see some helpful output about usage then the
installation was successful.
You should now be ready to go, but we should make sure. Start R-studio, and type
install.packages("SqlRender") library(SqlRender) translate("SELECT TOP 10 * FROM person;", "postgresql")
##  "SELECT * FROM person LIMIT 10;" ## attr(,"sqlDialect") ##  "postgresql"
This function uses Java, so if all goes well we know both R and Java have been installed correctly!
Another test is to see if source packages can be built. Run the
following R code to install the
CohortMethod package from
the OHDSI GitHub repository:
Installing HADES packages requires downloads from GitHub. Unfortunately, GitHub has a cap on how many downloads an anonymous user can make in a short amount of time, and this cap is reached when trying to download all HADES packages. To avoid this cap, we need to authenticate ourselves using our GitHub account. A known GitHub user has a much higher download cap, and can install HADES without issues. We can authenticate ourselves by first creating a Personal Access Token (PAT), and then providing this to R.
Fortunately, you will need to do this only once. After you’ve set your PAT in R, you can rely on it to be there in all your future R sessions.
Before we can create a PAT, you must make sure that you have a valid GitHub account. You can create one for free at GitHub.com.
The easiest way to create a GitHub PAT is by using the usethis package. Running this code will open a browser that allows you to generate a PAT:
install.packages("usethis") library(usethis) create_github_token(scopes = c("(no scope)"), description = "R:GITHUB_PAT", host = "https://github.com")
You may need to log on to GitHub. Note that the PAT does not require any of the permissions listed, so you can leave all checkboxes unchecked. Scroll down and click on ‘Generate token’ to generate your PAT. Your PAT is a sequence of 40 letters and numbers. Make sure to copy your PAT, because you will not be able to see it again once you close your browser!
Next, we need to make the PAT available to R. For this we need to add
a line to the
.Renviron file that looks like this:
GITHUB_PAT = 'a1b2c3d4e5f6g7h8g9h0ijklmnopqrstuvwxyz'
where ‘a1b2c3d4e5f6g7h8g9h0ijklmnopqrstuvwxyz’ is your PAT.
The easiest way to edit your
.Renviron file is by using
usethis package again:
This will open
.Renviron in a text editor. Add the line
with your PAT, save the file, and restart R. The PAT will now be
available to the various R functions.