The KidsFeet dataset comprises of 37 observations from fourth grade students in 1997.
Information collected included birthdate, which foot (Left/Right) is larger, the length and width of the child’s longer foot, sex, and dominant hand (Left/Right).
knitr::opts_chunk$set(message = FALSE)
library(mdsr)
library(RColorBrewer)
glimpse(KidsFeet)
## Rows: 39
## Columns: 8
## $ name <fct> David, Lars, Zach, Josh, Lang, Scotty, Edward, Caitlin, ...
## $ birthmonth <int> 5, 10, 12, 1, 2, 3, 2, 6, 5, 9, 9, 3, 8, 3, 11, 4, 12, 3...
## $ birthyear <int> 88, 87, 87, 88, 88, 88, 88, 88, 88, 88, 87, 88, 87, 88, ...
## $ length <dbl> 24.4, 25.4, 24.5, 25.2, 25.1, 25.7, 26.1, 23.0, 23.6, 22...
## $ width <dbl> 8.4, 8.8, 9.7, 9.8, 8.9, 9.7, 9.6, 8.8, 9.3, 8.8, 9.8, 8...
## $ sex <fct> B, B, B, B, B, B, B, G, G, B, B, B, B, B, G, G, G, G, G,...
## $ biggerfoot <fct> L, L, R, L, L, R, L, L, R, R, R, L, L, L, L, R, R, R, L,...
## $ domhand <fct> R, L, R, R, R, R, R, R, R, L, R, R, R, R, R, R, L, R, L,...
head(KidsFeet, n =5)
## name birthmonth birthyear length width sex biggerfoot domhand
## 1 David 5 88 24.4 8.4 B L R
## 2 Lars 10 87 25.4 8.8 B L L
## 3 Zach 12 87 24.5 9.7 B R R
## 4 Josh 1 88 25.2 9.8 B L R
## 5 Lang 2 88 25.1 8.9 B L R
We will use geom_violin and geom_jitter along with colour blind safe palettes from the RColorBrewer package.
Violin plots are a compact display of a continuous distribution, a blend of geom_boxplot and geom_density.
geom_jitter adds a small amount of random variation to the location of each point, a useful way of handling over-plotting caused by discreteness in smaller datasets.
We find that Boys tend to have larger feet length that girls.
q <- c(0.25, 0.5, 0.75)
KidsFeet %>% ggplot(aes(fill = sex,x = sex, y = length)) +
geom_violin(draw_quantiles = q, alpha = 0.6) +
scale_fill_brewer(palette = "Paired") +
geom_jitter(height = 0, width = 0.1)
We find that majority of the children are right handed, and there are more boys who are left handed than girls.
KidsFeet %>% ggplot(aes(x = sex, fill = domhand)) + geom_bar()