library(tidyverse)
library(knitr)
Let’s have a look at the iris
data set. The dataset contains 150 observations. We’ll also have a look at some chicken weights later.
iris %>%
group_by(Species) %>%
count(name = "Count")
Species | Count |
---|---|
setosa | 50 |
versicolor | 50 |
virginica | 50 |
iris %>%
ggplot(aes(Sepal.Length, Sepal.Width, color = Species)) +
geom_point() +
labs(title = "The iris data-set") +
theme_bw(base_size = 18) +
theme(legend.position = "bottom")
iris %>%
ggplot(aes(Species, Sepal.Length)) +
geom_violin(aes(fill = Species)) +
geom_boxplot(width = 0.1) +
theme_bw(base_size = 18) +
guides(fill = FALSE)
Let’s now have a look at ChickWeight
data. The dataset contains 578 observations and 50 chicks.
ChickWeight %>%
ggplot(aes(Time, weight, color = Diet)) +
geom_point() +
facet_wrap(~Chick) +
theme_minimal(base_size = 18)
sumdat <- ChickWeight %>%
filter(Time == max(Time)) %>%
group_by(Diet) %>%
summarise(Median = median(weight))
ChickWeight %>%
filter(Time == max(Time)) %>%
ggplot(aes(Diet, weight)) +
geom_point(size = 3, alpha = 1/3) +
theme_minimal(base_size = 18) +
geom_point(data = sumdat, aes(Diet, Median), color = "red", size = 5)