library(tidyverse)Task 2: Summarize and visualize
Getting started
Before you start, make sure to load the tidyverse package.
Count
Count the number of penguins on each island.
Count the number of penguins of each species on each island.
Summarize
Calculate mean flipper length and body mass for the 3 species separately.
Calculate mean flipper length and body mass by species and sex. Remove penguins with unknown sex first.
Combine dplyr and ggplot
Remove penguins with missing
sex, then pipe into a boxplot of body mass withsexon the x-axis.Remove penguins with missing
sex, then make a scatterplot of bill length vs. bill depth, colored by species.
For the fast ones
You can do these in any order, or skip them and just take a break.
A bit tricky: Summarize mean body mass by species, then pipe the result into a bar chart with
geom_col(). You haven’t seengeom_col()yet but it works like other geoms: map species toxand mean body mass toy.Calculate the min, max, and mean flipper length per species.
- Extra: Can you sort the result by mean flipper length? Hint: you’ll need
arrange()which we haven’t covered yet. Check?arrangeto figure out how it works.
- Extra: Can you sort the result by mean flipper length? Hint: you’ll need