Installation

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

is available for free for Windows, GNU/Linux and macOS.
As for now, the latest version is 4.3.2. Versions 4.2.0 or later are acceptable. Version 4.1.2 and older might experience issues. 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:

sudo apt-get install r-base r-base-dev

Install RStudio

RStudio Desktop is an Integrated Development Editor wrapping and interfacing that needs to be installed first. The free-version contains everything you need.

Visit the download page and choose the corresponding installer for your platform. As for now, the latest version is 2023.09.1+494.

Check the release notes to see if an update would be useful.

Open RStudio

They are four main panels in RStudio. After creating and executing a script, your interface might look like below.

Install the tidyverse package

For plotting, we will use the ggplot package, which is included in the tidyverse collection.

Several other libraries are required for successfully installing the ggplot but should install automatically, so we recommend installing the tidyverse package.

Install from the CRAN

CRAN - the Comprehensive R Archive Network - is the general package repository for.

In RStudio, the bottom-right panel holds five tabs.

  • Files
  • Plots
  • Packages
  • Help
  • Viewer

Click on the Packages tab (1.) and select the select the Install button (2.). Type dplyr in (3.). You will see the word auto-completion that helps.

It takes some time, usually 10 seconds up to several minutes for a single package depending on its size and compilation stage.

The packages can also be installed in the console (i.e. the bottom-left panel). The snapshot below shows you how to install remotes using the console:

Testing your installation

Copy / paste the code below and you should obtain the following plot.

suppressPackageStartupMessages(library(tidyverse))
# stopifnot(rstudioapi::isAvailable(version_needed = "2022.02.2.485"))
stopifnot(rlang::is_installed(c("ggplot2"), 
                              version = c("3.4.0")))
mtcars |>
  pivot_longer(cols = c(drat, wt),
               names_to = "measurement", 
               values_to = "value") %>%
  ggplot(aes(x = value, y = mpg, colour = measurement)) +
  geom_point() +
  geom_smooth(method = "loess") +
  theme_bw(14)

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 openssl

then in R, install the tidyverse.

install.packages("tidyverse")

If not, please contact me with a description of the error message.