Skip to content

Installing R

This page describes quick OS-specific steps to install R. If you are not familiar with installing software, you can consult this point-to-point guide.

  1. Download and run the CRAN installer for Windows
  2. Install Rtools (required for packages that compile native code)
    • Choose the Rtools version that matches your R release.
    • Make sure that R is added to your system path.

Verify installation:

R --version
Rscript -e "install.packages('jsonlite', repos='https://cloud.r-project.org'); cat('ok\n')"

If R is not found, R is most likely missing in your system variables. Open environmental variables and add the path to your R executable. R is most likely install at C:\Program Files\R\R-VERSION\bin\x64.

  1. Download and run the CRAN package for macOS
    • Alternatively install via Homebrew: brew install --cask r and optionally brew install r
  2. Install Xcode command line tools for compilers:

    xcode-select --install
    

Verify installation:

R --version
Rscript -e "install.packages('jsonlite', repos='https://cloud.r-project.org'); cat('ok\n')"
  1. Install R from the distribution repositories or CRAN (CRAN often provides newer versions). Example (Debian/Ubuntu):

    sudo apt-get update
    sudo apt-get install r-base r-base-dev
    
  2. Install build tools and Fortran for compiling packages:

    sudo apt-get install build-essential gfortran libblas-dev liblapack-dev
    

Verify installation:

R --version
Rscript -e "install.packages('jsonlite', repos='https://cloud.r-project.org'); cat('ok\n')"

Troubleshooting

  • If compilation fails, ensure Rtools is installed and added to your PATH.
  • Ensure Xcode command line tools are installed.
  • Ensure build-essential and gfortran are installed.