Counts vs. proportions (2)
Bar charts can tell dramatically different stories depending on whether they represent counts or proportions and, if proportions, what the proportions are conditioned on. To demonstrate this difference, you'll construct two bar charts in this exercise: one of counts and one of proportions.
Este ejercicio forma parte del curso
Análisis exploratorio de datos en R
Instrucciones del ejercicio
- Create a stacked bar chart of
gendercounts withalignon the x-axis. - Create a stacked bar chart of
genderproportions withalignon the x-axis by setting thepositionargument togeom_bar()equal to"fill".
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# Plot of gender by align
ggplot(comics, aes(x = ___, fill = ___)) +
geom_bar()
# Plot proportion of gender, conditional on align
ggplot(comics, aes(x = ___, fill = ___)) +
geom_bar(position = ___) +
ylab("proportion")