Hands-on Exercise: Advance Data Manipulation

Materials adapted from Adrien Osakwe, Larisa M. Soto and Xiaoqi Xie.

suppressPackageStartupMessages(library(gapminder))
suppressPackageStartupMessages(library(dplyr))

Write one command ( can span multiple lines) using pipes that will output a data frame that has only the columns lifeExp, country and year for the records before the year 2000 from African countries, but not for other Continents.

Calculate the average life expectancy per country. Which country has the longest average life expectancy and which one the shortest average life expectancy?

In the previous hands-on you discovered that all the entries from 2007 are actually from 2008. Write a command to edit the data accordingly using pipes. In the same command filter only the entries from 2008 to verify the change.