Setup and installation of R for the "Using R in an HPC environment" course
The purpuse of this documentation is mainly for setting up R, RStudio, and some R packages on your computer in preparation for the "Using R in an HPC environment" course that is given at HPC2N on 25-26 February 2021.
Before the course, please
- Install R, if you do not already have it installed. There are instructions below for various operating systems.
- Install RStudio, if you do not already have it installed. Again, there are instructions below.
- 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
- Pick "R for Windows" from the nearest download mirror: UmU | Pick different mirror
- Choose the precompiled binary for the base distribution (the "install R for the first time" link)
- Download and install the .exe file (R-4.0.4-win.exe for the newest)
- For an older version, go here. The 3.6.2 version is guaranteed to work with the packages for this course.
RStudio
The base version of RStudio is free. It should suffice for the purposes of the course.
- Go to the download page for RStudio and pick the "Free" version
- 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:
- Find the name of the package you want, for example from the list of R packages
- Start the "R" program
- In the top menu of the window that opens, click “Packages”,then click “Install package(s)”.
- Choose a mirror that is close to your geographical location. There should be one for "ACC, Umeå University"
- Choose the package you wish to install. You can hold down the CTRL key to highlight and pick multiple packages.
- Click "OK"
- 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
- Start the "R" program if it is not already running
- Type “library(RPACKAGE)”, where RPACKAGE should be changed to the name of the specific R package in question. Then press the Enter/Return key.
- The package should now be loaded and available.
macOS
R
- Pick "Download R for (Mac) OS X" from the nearest download mirror: UmU | Pick different mirror
- 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.
- 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.
- Go to the download page for RStudio and pick the "Free" version
- Scroll down a little and pick the macOS 10.13+ .dmg file to download.
- 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:
- Find the name of the package you want, for example from the list of R packages
- Start Spotlight to find and start the "R" ("R64" if you have) program
- Wait for R to start. Now, in the top menu, click “Packages & Data”, then click “Package Installer”.
- 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.
- In the pop-up window, make sure "Install Dependencies" is checked. Click "Update All" and "OK".
- Choose the package you wish to install from the list. You can search for it as well. Again, make sure "Install Dependencies" is checked.
- Click "Install Selected".
- 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:
- Start the "R" program
- Type “install.packages(“RPACKAGE”)”, where RPACKAGE should be changed to the name of the specific package in question. Then press the Enter/Return key.
- If you have not installed other packages during this session, you will be prompted to choose a mirror to download from.
- When your window prompt returns to a ">" the package has finished downloading and installing.
R packages - loading into R
- Start the "R" program if it is not already running
- Type “library(RPACKAGE)”, where RPACKAGE should be changed to the name of the specific R package in question. Then press the Enter/Return key.
- The package should now be loaded and available.
Linux
There are detailed instructions for installation on Ubuntu 16.04, 18.04, 19.10, 20.04 and 20.10 on a google document.
R
You can either download precompiled binaries or compile from source. Links can be found from the The Comprehensive R Archive Network
- Linux Ubuntu
- sudo apt-get update
- sudo apt-get install r-base
- Other Linux distro
- Pick "Download R for Linux" from the nearest download mirror: UmU | Pick different mirror
- Choose a suitable distro
- 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.
- Go to the download page for RStudio and pick the "Free" version
- Scroll down a little and pick the Linux binary that fits your distro. Download the file and install it. On Ubuntu, this is done with
sudo dpkg -i <file>
- RStudio depends on a package that you may have to install, namely
- libclang-dev
- You can install it on Ubuntu with
sudo apt-get install libclang-dev
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:
- Find the name of the package you want, for example from the list of R packages
- Start the "R" program
- Type “install.packages(“RPACKAGE”)”, where RPACKAGE should be changed to the name of the specific package in question. Then press the Enter/Return key.
- If you have not installed other packages during this session, you will be prompted to choose a mirror to download from.
- 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
- Start the "R" program if it is not already running
- Type “library(RPACKAGE)”, where RPACKAGE should be changed to the name of the specific R package in question. Then press the Enter/Return key.
- 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 16.04, 18.04, 19.10, 20.04 and 20.10 on a google document.
Local machine
- 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
- If R version > 3.5. Using BiocManager
- rbenchmark
- microbenchmark
- compiler
- ggplot2
- tidyverse
- matrixStats
- pryr
- lineprof [use the devtools: devtools::install_github("hadley/lineprof") ]
- Note that in some versions of R (on Ubuntu at least) you need to install devtools first, the same way you installed the other R packages.
- bigmemory
- event
Kebnekaise
- bigmemory
- doParallel
- tidyverse
- caret
- randomForest
- e1071
- C50