BaşlayınÜcretsiz Başlayın

Exploring world life expectancy

The two data.tables from the previous exercise have been loaded into your workspace:

  • life_exp: contains the life expectancy of each country in 2010 sourced from the Gapminder foundation
  • continents: contains a mapping between each country and the continent(s) they are part of built from information provided by Countries-ofthe-World.com.

Your goal this time is to calculate the average life expectancy across countries within each continent.

Bu egzersiz

Joining Data with data.table in R

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

Inner join life_exp to continents and calculate the mean() (docs) "years" of life expectancy grouped by the "continent" column.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Calculate average life expectancy per continent:
avg_life_expectancy <- continents[life_exp, on = .(country), 
                                  ___][, j = ___, 
                                       by = ___]
avg_life_expectancy
Kodu Düzenle ve Çalıştır