Setup and installation of R for the "Scientific Computing in R" course

Setup and installation of R for the "Scientific Computing in R" course

The purpuse of this documentation is mainly for setting up R, RStudio, and some R package in preparation for the "Scientific Computing in R" course that is given at HPC2N on 27 May 2020.

Before the course, please

  1. Install R, if you do not already have it installed. There are instructions below various operating systems.
  2. Install RStudio, if you do not already have it installed. Again, there are instructions below.
  3. There is a list of R packages needed for the course. Please install them. Instructions for installing R packages in general is under each section for the specific operating system and the list of R packages needed is listed at the bottom of this page.

NOTE: These instructions assume that you have admin rights/root permission to the computer you are using. If you have permission problems installing R, RStudio, or any Rpackages, please look at this FAQ.

 
R is a free software environment for statistical computing and graphics. It compiles and runs on a wide variety of UNIX platforms, Windows and MacOS.
 

Windows

R

  1. Pick "R for Windows" from the nearest download mirror: UmU | Pick different mirror
  2. Choose the precompiled binary for the base distribution (the "install R for the first time" link)
  3. Download and install the .exe file (R-4.0.0-win.exe)

RStudio

The base version of RStudio is free. It should suffice for the purposes of the course.

  1. Go to the download page for RStudio and pick the "Free" version
  2. Scroll down a little and pick the Windows .exe file to download and install, following the instructions of the installer

R packages - installing

You will find a list of R packages here. The link goes to the mirror located in Umeå, but you can find other mirrors from this page.

You can see which packages are already installed by starting R and giving the command

installed.packages()

NOTE: The list of packages needed for the course is here.

There are several procedure for installing R packages, but the simplest is to do it through R:

  1. Find the name of the package you want, for example from the list of R packages
  2. Start the "R" program
  3. In the top menu of the window that opens, click “Packages”,then click “Install package(s)”.
  4. Choose a mirror that is close to your geographical location. There should be one for "ACC, Umeå University"
  5. Choose the package you wish to install. You can hold down the CTRL key to highlight and pick multiple packages.
  6. Click "OK"
  7. When your window prompt returns to a ">" the package has finished downloading and installing.

Only do the above once per package.

R packages - loading into R

  1. Start the "R" program if it is not already running
  2. Type “library(RPACKAGE)”, where RPACKAGE should be changed to the name of the specific R package in question. Then press the Enter/Return key.
  3. The package should now be loaded and available.

macOS

R

  1. Pick "Download R for (Mac) OS X" from the nearest download mirror: UmU | Pick different mirror
  2. Choose the latest binary for the base distribution. Note that you may need to install XQuartz if not already installed, if you need to use X11.
  3. Download and install the .pkg file (R-4.0.0.pkg) by double-clicking on it.

RStudio

The base version of RStudio is free. It should suffice for the purposes of the course.

  1. Go to the download page for RStudio and pick the "Free" version
  2. Scroll down a little and pick the macOS 10.13+ .dmg file to download. 
  3. When it has downloaded, double-click it to open, and then drag and drop it to your applications folder.

R packages - installing

You will find a list of R packages here. The link goes to the mirror located in Umeå, but you can find other mirrors from this page.

You can see which packages are already installed by starting R and giving the command

installed.packages()

NOTE: The list of packages needed for the course is here.

On macOS install.packages works as it does on other Unix-alike systems, but there is an additional type mac.binary (available for the CRAN distribution but not when compiling R from source) which can be passed to install.packages in order to download and install binary packages from a suitable repository. These binary package files for macOS have the extension ‘.tgz’. The R.APP GUI provides menus for installation of either binary or source packages, from CRAN or local files.

There are several procedure for installing R packages, but the simplest is to do it through R:

  1. Find the name of the package you want, for example from the list of R packages
  2. Start Spotlight to find and start the "R" ("R64" if you have) program
  3. Wait for R to start. Now, in the top menu, click “Packages & Data”, then click “Package Installer”.
  4. Click "Get List". The first time it will ask you to choose a mirror. Pick one that is close to your geographical location. There should be one for "ACC, Umeå University". Pick that if you are in Sweden. You can set it as default to avoid being asked every time.
  5. In the pop-up window, make sure "Install Dependencies" is checked. Click "Update All" and "OK".
  6. Choose the package you wish to install from the list. You can search for it as well. Again, make sure "Install Dependencies" is checked.
  7. Click "Install Selected".
  8. When your window prompt returns to a ">" the package has finished downloading and installing.

Only do the above once per package.

Another, faster method of installing packages is the following, though it requires that you know the name of the package:

  1. Start the "R" program
  2. Type “install.packages(“RPACKAGE”)”, where RPACKAGE should be changed to the name of the specific package in question. Then press the Enter/Return key.
  3. If you have not installed other packages during this session, you will be prompted to choose a mirror to download from.
  4. When your window prompt returns to a ">" the package has finished downloading and installing.

R packages - loading into R

  1. Start the "R" program if it is not already running
  2. Type “library(RPACKAGE)”, where RPACKAGE should be changed to the name of the specific R package in question. Then press the Enter/Return key.
  3. The package should now be loaded and available.

Linux

R

You can either download precompiled binaries or compile from source. Links can be found from the The Comprehensive R Archive Network

  1. Linux Ubuntu
    1. sudo apt-get install r-base
  2. Other Linux distro
    1. Pick "Download R for Linux" from the nearest download mirror: UmU | Pick different mirror
    2. Choose a suitable distro
    3. Look at the "README" file in the directory to see how easiest to install R and the distributed packages.

RStudio

The base version of RStudio is free. It should suffice for the purposes of the course.

  1. Go to the download page for RStudio and pick the "Free" version
  2. Scroll down a little and pick the Linux binary that fits your distro. Download the file and install it.

R packages - installing

You will find a list of R packages here. The link goes to the mirror located in Umeå, but you can find other mirrors from this page.

You can see which packages are already installed by starting R and giving the command

installed.packages()

NOTE: The list of packages needed for the course is here.

There are several procedure for installing R packages, but the simplest is to do it through R:

  1. Find the name of the package you want, for example from the list of R packages
  2. Start the "R" program
  3. Type “install.packages(“RPACKAGE”)”, where RPACKAGE should be changed to the name of the specific package in question. Then press the Enter/Return key.
  4. If you have not installed other packages during this session, you will be prompted to choose a mirror to download from.
  5. When your window prompt returns to a ">" the package has finished downloading and installing.

This should be done only once for each package.

R packages - loading into R

  1. Start the "R" program if it is not already running
  2. Type “library(RPACKAGE)”, where RPACKAGE should be changed to the name of the specific R package in question. Then press the Enter/Return key.
  3. The package should now be loaded and available.

List of R packages to install

This is the list of packages that we will use for the course. Please install them before the beginning of the course.

There are detailed instructions for installation on Ubuntu 18.04 and 20.04 on a google document

  • tictoc
  • proftools
    • install.packages("proftools")
    • After installing package 'proftools', we also need to install some packages for graphical display: 'graph' and Rgraphviz'. This is done differently depending on your version of R
      • If R version < 3.5. Using biocLite
        • 
          source("http://bioconductor.org/biocLite.R")
          biocLite(c("graph","Rgraphviz"))
          
      • If R version > 3.5. Using BiocManager
        • 
          if (!requireNamespace("BiocManager", quietly = TRUE))
            install.packages("BiocManager")
          BiocManager::install()
          BiocManager::install(c("graph","Rgraphviz"))          
  • rbenchmark
  • microbenchmark
  • hash
  • compiler
  • ggplot2
  • RhpcBLASctl
  • matrixStats
  • pryr
  • lineprof [use the devtools:  devtools::install_github("hadley/lineprof") ]
  • bigmemory
  • doParallel
  • tidyverse
  • caret
  • randomForest
  • e1071
Updated: 2024-04-17, 14:47