MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Introduction to the Tidyverse

Lihat Kursus

Petunjuk latihan

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

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

library(gapminder)
library(dplyr)

# Summarize to find the median life expectancy
Edit dan Jalankan Kode