The RSA
select
or filter
and create new columns with mutate
.%>%
.summarise
, group_by
, and count
to split a data frame into groups of observations, apply summary statistics for each group, and then combine the results.ggplot
plot (including axis labels and color)ggplot2
?ggplot2
ggplot2 is a package (included in the tidyverse
) for creating highly customisable plots that are built step-by-step by adding layers.
The separation of a plot into layers allows a high degree of flexibility with minimal effort.
ggplot2
layers
<DATA> %>%
ggplot(aes(<MAPPINGS>)) +
<GEOM_FUNCTION>() +
<CUSTOMISATION>
Whenever we visualise data, we take data values and convert them in a systematic and logical way into the visual elements that make up the final graphic. […] All data visualisations map data values into quantifiable features of the resulting graphic. We refer to these features as aesthetics.
In the previous game, people with the most common type of colour-blindness would have struggled to perceive the colour distinction 😱
Are colourblind-friendly…
… and they’re very pretty 😍✨
⏰ 5 mins
05:00
Use what you just learned to create a scatter plot of cars
by household_size
with the dwelling_type
showing in different colours.
⏰ 10 mins
10:00
Replace the box plot with a violin plot; see geom_violin()
.
⏰ 5 mins
05:00
Build the previous plot again and experiment with at least two themes.
Which do you like best?
theme_minimal
theme_void
theme_classic
theme_dark
theme_grey
theme_light
I prefer the white background of theme_minimal
and I like that it retains the major grid, though that’s slightly controversial.
I also like that it gets rid of the black box around the plot.
ggplot2
and compatible packages give you a huge amount of flexibility to create exactly the graph you want!
You can explore packages that let you play around with:
ghibli
, wesanderson
),hrbrthemes
)extrafont
)gganimate
)