library(palmerpenguins)
head(penguins, 7)(A few remarks and tips before the practical session)
(Subjectively.)
(Objectively. 🙂)
A formal syntax and grammar for describing visualizations
| species | island | bill_length_mm | bill_depth_mm | flipper_length_mm | body_mass_g | sex | year |
|---|---|---|---|---|---|---|---|
| Adelie | Torgersen | 39.1 | 18.7 | 181 | 3750 | male | 2007 |
| Adelie | Torgersen | 39.5 | 17.4 | 186 | 3800 | female | 2007 |
| Adelie | Torgersen | 40.3 | 18.0 | 195 | 3250 | female | 2007 |
| Adelie | Torgersen | NA | NA | NA | NA | NA | 2007 |
| Adelie | Torgersen | 36.7 | 19.3 | 193 | 3450 | female | 2007 |
| Adelie | Torgersen | 39.3 | 20.6 | 190 | 3650 | male | 2007 |
| Adelie | Torgersen | 38.9 | 17.8 | 181 | 3625 | female | 2007 |
par(mfrow = c(1, 3))
species_1 <- filter(penguins, species == "Adelie")
hist(species_1$body_mass_g, xlim = c(2000, 8000),
main = "Species 'Adelie'",
xlab = "Body mass [grams]",
col = "darkgreen", border = "white")
species_2 <- filter(penguins, species == "Chinstrap")
hist(species_2$body_mass_g, xlim = c(2000, 8000),
main = "Species 'Chinstrap'",
xlab = "Body mass [grams]",
col = "darkblue", border = "white")
species_3 <- filter(penguins, species == "Gentoo")
hist(species_3$body_mass_g, xlim = c(2000, 8000),
main = "Species 'Gentoo'",
xlab = "Body mass [grams]",
col = "darkorange", border = "white")A “mini-language” with verbs like select(), filter(), etc.
(Helps us avoid “R bootcamp”-level nightmares.)
(To make visualizations easier in a similar sense.)
data — our data frameaesthetics — “mapping” of columns to visual properties of a figure (x, or y axes, color, shape, etc.)geoms — graphical elements to be plotted (histograms, points, lines, etc.).A quick advertisement for the “layering” concept of ggplot2
x “aesthetic”)x “aesthetic”)fill “aesthetic”)We need to make a copy of an IBD processing pipeline.
ggplot2 version 4.0.0 was released just a few days ago. 🤞😬