Hands-on Exercise: Basic Data Manipulation

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

library(gapminder)

Writing data

Write a data processing snippet to include only the data points collected after 1995 in Asian countries as a CSV file

Separate the gapminder data frame into 5 individual data frames, one for each continent. Store those 5 data frames as an RData file in the objects folder called continents.RData.

Exploring data frames

Finish exploring the gapminder data frame and:

  • Find the number of rows and the number of columns
  • Print the data type of each column
  • Explain the meaning of everything that str(gapminder) prints

In which years has the GDP of Canada been larger than the average of all data points?

Find the mean life expectancy of Switzerland before and after 2000

You discovered that all the entries from 2007 are actually from 2008. Create a copy of the full gapminder data frame in an object called gp. Then change the year column to correct the entries from 2007.

Bonus - Find the mean life expectancy and mean gdp per continent using the function tapply