Calculate spread measures
Let's extend the powerful group_by() and summarize() syntax to measures of spread. If you're unsure whether you're working with symmetric or skewed distributions, it's a good idea to consider a robust measure like IQR in addition to the usual measures of variance or standard deviation.
Este ejercicio forma parte del curso
Análisis exploratorio de datos en R
Instrucciones del ejercicio
The gap2007 dataset that you created in an earlier exercise is available in your workspace.
- For each continent in
gap2007, summarize life expectancies using thesd(), theIQR(), and the count of countries,n(). No need to name the new columns produced here. Then()function within yoursummarize()call does not take any arguments. - Graphically compare the spread of these distributions by constructing overlaid density plots of life expectancy broken down by continent.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# Compute groupwise measures of spread
gap2007 %>%
group_by(___) %>%
summarize(___,
___,
___)
# Generate overlaid density plots
gap2007 %>%
ggplot(aes(x = ___, fill = ___)) +
geom_density(alpha = 0.3)