Introduction to R and RStudio


Figure 1

Meet the penguins cartoon illustration of the penguin species Chinstrap! Adelie! and Gentoo! by @Allison Horst (CC-BY-4.0)
Meet the penguins cartoon illustration of the penguin species Chinstrap! Adelie! and Gentoo! by @Allison Horst (CC-BY-4.0)

Figure 2

RStudio layout

Figure 3

RStudio layout with .R file open

Figure 4

Screenshot of file manager demonstrating bad project organisation

Data Structures and Subsetting Data


Exploring Data Frames


R Packages and Seeking Help


Manipulating Tibbles With Dplyr


Figure 1

Cartoon illustration of bill length and depth by @Allison Horst (CC-BY-4.0);
An illustration of Bill Length and Depth Artwork by @allison_horst

Figure 2

Diagram illustrating use of select function to select two columns of a data frame

Figure 3

Cartoon showing three fuzzy monsters either selecting or crossing out rows of a data table. If the type of animal in the table is “otter” and the site is “bay”, a monster is drawing a purple rectangle around the row. If those conditions are not met, another monster is putting a line through the column indicating it will be excluded. Stylized text reads "dplyr::filter() - keep rows that satisfy your conditions."
filter() keeps rows that satisfy your conditions -Artwork by @allison_horst

Figure 4

Diagram illustrating how the group by function oraganizes a data frame into groups

Figure 5

Diagram illustrating the use of group by and summarize together to create a new variable

Figure 6

Cartoon of cute fuzzy monsters dressed up as different X-men characters, working together to add a new column to an existing data frame. Stylized title text reads "dplyr::mutate - add columns, keep existing."
An illustration of the mutate function Artwork by @allison_horst

Creating Publication-Quality Graphics with ggplot2


Figure 1

Blank plot, before adding any mapping aesthetics to ggplot().

Figure 2

Plotting area with axes for a scatter plot of mean body mass vs year, with no data points visible.

Figure 3

Scatter plot of mean body mass vs year, now showing the data points.

Figure 4

Scatter plot showing bill length (mm) versus flipper length (mm) for individual penguins, displaying each species as distinct points. All points are coloured on the plot are coloured black.
Scatter plot showing bill length (mm) versus flipper length (mm) for individual penguins, displaying each species as distinct points. All points are coloured on the plot are coloured black.

Figure 5

Scatter plot of body mass (g) vs flipper length (mm), with points color-coded by penguin species to show how body mass varies by species and flipper length, thus showing the value of 'aes' function
Scatter plot of body mass (g) vs flipper length (mm), with points color-coded by penguin species to show how body mass varies by species and flipper length, thus showing the value of ‘aes’ function

Figure 6


Figure 7


Figure 8


Figure 9


Figure 10


Figure 11

Scatter plot of mran body mass (g) over time, with lines connecting values for each year and species, demonstrating species-specific trends in body mass across years

Figure 12


Figure 13

Scatter plot of flipperer length vs bill length with a blue trend line summarising the relationship between variables, and gray shaded area indicating 95% confidence intervals for that trend line.

Figure 14

Scatter plot of flipper length vs bill length with a trend line summarising the relationship between variables. The trend line is slightly thicker than in the previous figure.

Figure 15

Scatter plot of average body mass (g) over time, showing enlarged orange data points for each year, connected by lines colored by species.

Figure 16

Scatter plot of flipper length (mm) against bill length (mm).

Figure 17


Figure 18


Figure 19

Boxplot comparing flipper length (mm) across penguin species, with labeled axes showing species on the x-axis and flipper length on the y-axis, and the legend hidden for a cleaner view.

Wrap-up