Skip to main content

More data visualisation in R

Author: Samvida Venkatesh.

Welcome! In this tutorial we will further explore ways to visualise data using the R packages dplyr and ggplot2.

Getting set up

dplyr and ggplot2 are part of tidyverse. If you followed the tidyverse installation section you'll have this already - if not let's install it now:

install.packages("tidyverse") 

We'll use real data on population size, life expectancy and GDP from gapminder.org, and ecological data from palmerpenguins, so let's install those packages too:

install.packages("gapminder")
install.packages("palmerpenguins")

Lastly to make good-looking plots we need cool colour palettes - Color Brewer is one of these so let's install:

install.packages("RColorBrewer")

Load these into a running R session:

library(ggplot2)
library(dplyr)
library(RColorBrewer)

As a last step we are going to default to a 'bw' style of plots, so let's set out ggplot2 theme now:

ggplot2::theme_set(theme_bw())