Aan de slagGa gratis aan de slag

Summarizing the median life expectancy

You've seen how to find the mean life expectancy and the total population across a set of observations, but mean() and sum() are only two of the functions R provides for summarizing a collection of numbers. Here, you'll learn to use the median() function in combination with summarize().

By the way, dplyr displays some messages when it's loaded that we've been hiding so far. They'll show up in red and start with:

Attaching package: 'dplyr'

The following objects are masked from 'package:stats':

This will occur in future exercises each time you load dplyr: it's mentioning some built-in functions that are overwritten by dplyr. You won't need to worry about this message within this course.

Deze oefening maakt deel uit van de cursus

Introduction to the Tidyverse

Cursus bekijken

Oefeninstructies

  • Use the median() function within a summarize() to find the median life expectancy. Save it into a column called medianLifeExp.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

library(gapminder)
library(dplyr)

# Summarize to find the median life expectancy
Code bewerken en uitvoeren