sudo apt-get install r-base r-base-devInstallation
Prerequisites
You need to bring a laptop to conduct the exercises. You also need to install software to participate in this course. Please let us know if you experience issues in the installation. Please try the installation before you attend the meeting, particularly if you are using a device provided through your employer with possibly limited administrator rights.
Please check your setup after installation.
Installation
R is available for free for Windows, GNU/Linux and macOS.
As for now, the latest version is 4.5.2. Only versions 4.5.0 or later are acceptable!
Please upgrade if your system is running an older version.
Windows and macOS
Visit the download page and choose the corresponding installer for your platform.
GNU/Linux
Any GNU/Linux distributions is bundled with a great package manager such as dpkg or rpm. Visit the appropriate web-page for your distribution here.
After you get the correct entry in your package manager, it should be quite easy as:
Install Positron
Positron is an integrated development environment (IDE) for data science from Posit, the company behind RStudio. It works with , which needs to be installed first: Positron finds your R installation and does not bring its own. Positron is free.
Visit the Positron download page and choose the installer for your platform.
Please update Positron to the current version if you had it previously installed.
Install the tidyverse package
For plotting, we will use the ggplot2 package, which is included in the tidyverse collection.
The tidyverse pulls in several other packages that ggplot2 and the course need, so we recommend installing the tidyverse package as a whole.
Install from the CRAN
CRAN, the Comprehensive R Archive Network, is the general package repository for .
Open Positron and start an R session. In the Console, at the bottom of the window, type:
install.packages("tidyverse")Installation takes from a few seconds to several minutes per package, depending on its size and whether it needs to be compiled.
Testing your installation
Copy / paste the code below and you should obtain the following plot.
suppressPackageStartupMessages(library(tidyverse))
stopifnot(rlang::is_installed(c("ggplot2"),
version = c("3.5.0")))
penguins |>
ggplot(aes(x = bill_len, y = flipper_len, colour = species)) +
geom_point() +
geom_smooth(method = "lm") +
theme_bw(14)`geom_smooth()` using formula = 'y ~ x'
Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_smooth()`).
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).

Code versioning
Git installation
Git has become the prevalent code versioning system and will be used in this course. You can skip to test your installation of git and GitHub if you have it installed already and configure SSH to access GitHub.
In any case test your setup.
Windows
The recommended way to install Git on Windows is via Git for Windows, which includes Git Bash, which will install other useful tools. Please download it from Git and start a bash shell by opening Git Bash.
macOS
Check if you have Git already installed by running in the terminal:
git versionThis should put out the current version of your Git installation or an error message such as command not found.
If you do not have Git installed please run the following line in your terminal to install it:
xcode-select --installGNU/Linux
Check if you have Git already installed by running in the terminal:
git versionThis should put out the current version of your git installation or an error message such as command not found.
If you do not have Git installed please run in the terminal:
sudo apt-get install gitGit configuration
Windows/macOS/GNU/Linux users
Positron uses the Git installed on your system and shows it in the Source Control view of the Activity Bar on the left. You can run the commands below in Positron’s terminal (Terminal > New Terminal), in Git Bash, or in the terminal on macOS or Linux.
After you have installed Git/Git Bash, configure it by typing in the terminal/Bash:
git config --global user.name "Firstname Lastname"
git config --global user.email "yourEmail@server.com"Check the configuration by running:
git config --listYou should be able to see your user.name and user.email set accordingly.
Configure your machine to access GitHub
For the practicals, we create a private repository on GitHub for each participant. Please make sure you have an account that you can access, and send us your GitHub username when you register.
Go the GitHub signup page. A free account will do for the exercises. We recommend setting up two-factor authentication right away.
If you use older accounts, make sure that you have a working system.
A SSH key deposited at GitHub and connections via ssh are the method of choice for this course.
How SSH (Secure SHell) works briefly is presented below:
Figure from the UL-HPC technical documentation
Check if a SSH key already exists by running in the terminal/Bash:
ls -al ~/.sshIf there are id_ed25519 and id_ed25519.pub files you already have a pair of SSH keys (private and public, respectively). An older key pair named id_rsa and id_rsa.pub works as well; in that case use these file names in the commands below.
If you do not have it yet you have to generate it with the following lines:
- Ensure that the folder
.sshis present:
mkdir -p ~/.ssh- Generate the key pair, using the email address of your GitHub account:
ssh-keygen -t ed25519 -C "yourEmail@server.com"Accept the default location by pressing ENTER to the question Enter file in which to save the key (...)
It will then ask you to generate a password, it is recommended to have one.
The successful output should be something like:
[...]
Your identification has been saved in /your_home/.ssh/id_ed25519
Your public key has been saved in /your_home/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:sgqajbjvc/NOSyfR4hURB4Mvw6BEV/5HB6OWf134wq8 yourEmail@server.com
The key's randomart image is:
+--[ED25519 256]--+
| .. ....=o+ |
| ..... * o . |
| . . o..= . . . .|
| . ++.+ . o o |
| +oS o . + .|
| . * . . o |
| . * . .|
|.=..o+ + . |
|*++o.++ E |
+----[SHA256]-----+If you have entered a password, you need to add the private SSH key (id_ed25519) to the ssh-agent by running the following commands:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519First command returns the process ID of the agent (for example Agent pid 247), the second should return Identity added: /your_home/.ssh/id_ed25519 (yourEmail@server.com)
To use the SSH key you should copy the public SSH key (id_ed25519.pub) to the clipboard. You can display it with:
cat ~/.ssh/id_ed25519.pubOf note, you can use nano or any text editor to open the id_ed25519.pub file.
The key starts with ssh-ed25519 and ends with your email, like this example:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBT59tKvEYlNctcGdYriVhdE5i6+wprPTxiNg0y3J9Ys yourEmail@server.comSelect and copy the totality to the clipboard.
Finalise the connection
Go to your GitHub account, open Settings.
In the SSH and GPG keys section add your public SSH key by clicking the New SSH key button.
Give the key a name of your choice (e.g.
my_laptop) and paste it in the Key field.Check that the SSH key is listed under SSH keys.
More information can be found on this page.
Troubleshooting
If you encountered issues with package installation on Mac or Linux, install them with:
- in a terminal, for GNU/Linux:
sudo apt install -y libcurl4-openssl-dev libssl-dev libxml2-dev- in a terminal, for MacOS and
brew:
brew install libxml2 opensslthen in R, install the tidyverse.
install.packages("tidyverse")If not, please contact me with a description of the error message.