head(iris)
pivot_longer()
and separate()
functions in the tidyr packagelibrary(tidyverse) iris %>% pivot_longer(cols = -Species, names_to = “Part”, values_to = “Value”) %>% separate(col = “Part”, into = c(“Part”, “Measure”))
group_by()
and summarize()
functions in the dplyr packagePart
variable in our tidy data,Value
by Species
and Part
iris %>% pivot_longer(cols = -Species, names_to = “Part”, values_to = “Value”) %>% separate(col = “Part”, into = c(“Part”, “Measure”)) %>% group_by(Species, Part) %>% summarize(m = mean(Value))
ggplot()
function in the ggplot2
packageiris %>% pivot_longer(cols = -Species, names_to = “Part”, values_to = “Value”) %>% separate(col = “Part”, into = c(“Part”, “Measure”)) %>% ggplot(aes(x = Value, color = Part)) + geom_boxplot()