International College of Digital Innovation, CMU
July 2, 2025
About This Data Set
Gapminder
is a sample dataset available in the gapminder
package in R. It is designed for teaching and learning about data analysis, particularly for creating visualizations and performing data exploration using ggplot2
and other tools in R.
This dataset presents indicators related to economic and health metrics across various countries around the world during the period 1952–2007.
The data is provided by the Gapminder Foundation, an organization that develops learning tools about the world and sustainable development.
Variables in the Gapminder Dataset
The Gapminder dataset contains six main variables:
country
: The name of the country (e.g., Afghanistan, Brazil, China)
continent
: The continent where the country is located (Africa, Americas, Asia, Europe, Oceania)
year
: The year the data was recorded (1952, 1957, 1962, …, 2007)
lifeExp
: Life expectancy of the population in each country (unit: years)
pop
: Population of the country
gdpPercap
: GDP per capita, calculated by dividing the country’s GDP by its population (unit: US dollars)
You can download this dataset from
Google Drive
to explore and study in the upcoming topics.
You must convert your data range into an Excel Table first:
Select the data that you want to convert into a table.
Go to “Insert” → “Table”.
Make sure to check whether your data has headers.
Click OK → Your data will be converted into a dynamic Excel Table.
How to Use the Shortcut to Convert Data into a Table
Select the data range you want to convert into a table. (Press Ctrl + A (or Command + A on Mac))
Press Ctrl + T (or Command + T on Mac).
The Create Table dialog box will appear.
Check “My table has headers” if your data includes headers.
Click OK → The data will be instantly converted into a Table!
Easily filter and sort your data
Apply styles and formatting automatically
Automatically expand when new data is added
Conveniently use with Pivot Tables, Charts, and Power Query
Extra Tip:
If you want to remove the table but keep the data, press Ctrl + Shift + T,
or go to Table Design → Convert to Range to convert the table back to a normal range.
Filtering is a feature that allows you to view only specific data in your table, such as filtering by values, numbers, dates, or text. Follow the steps below:
How to Use the Filter Tool
Select the Data Range
Enable the Filter
Go to the Data tab on the Ribbon and click Filter
(or press Ctrl + Shift + L on Windows).
Small dropdown arrows will appear on the column headers.
Apply Filters
Click the arrow in the header of the column you want to filter.
Choose a filter type such as:
Text Filters: For text-based conditions (e.g., begins with, contains, does not equal).
Number Filters: For numeric conditions (e.g., greater than, less than, between).
Date Filters: For dates (e.g., today, yesterday, this week).
You can also uncheck specific values to display only the data you want.
Clear Filters
Click the arrow in the filtered column and select Clear Filter.
Or go to the Data tab and click Filter again to turn it off entirely.
Steps:
Click the header of the continent column.
Use the filter dropdown to select only Asia.
Result:
You will see only data for countries in the Asian continent, such as Afghanistan, China, and India.
Steps:
Click the header of the year column.
Use Number Filters, select Equals, and enter 2007
.
Result:
You will see only data for all countries in the year 2007.
Steps:
Click the header of the lifeExp column.
Use Number Filters, select Greater than, and enter 70
.
**Result:
You will see only countries with a life expectancy above 70 years, such as Japan and Sweden.
Steps:
Click the header of the gdpPercap column.
Use Number Filters, select Greater than, and enter 10000
.
Result:
You will see only countries with high GDP per capita, such as the USA and Norway.
Steps:
Click the header of the pop column.
Use Number Filters, select Between, and enter the range 1,000,000
to 10,000,000
.
Result:
You will see only countries with a population in that range, such as Jordan and Finland.
1. Which countries in Africa had a life expectancy (lifeExp) of less than 50 years in 1962?
Hint:
Use a filter on the continent column and select Africa.
Then filter the year column by selecting 1962.
Finally, filter the lifeExp column with the condition Less than 50.
2. Find countries with a population (pop) greater than 100 million in the year 2002
Hint:
Filter the year column by selecting 2002.
Use a filter on the pop column with the condition Greater than 100,000,000.
3. Which countries in Europe had a GDP per capita (gdpPercap) less than $5,000 in the year 1987?
Hint:
Filter the continent column by selecting Europe.
Set a filter on the year column to 1987.
Use a filter on the gdpPercap column with the condition Less than 5000.
4. Which countries had the highest GDP per capita (gdpPercap) in each continent in the year 1957?
Hint:
Filter the year column by selecting 1957.
Sort the gdpPercap column in descending order.
Use the continent filter to identify the top country in each continent.
5. Find countries with a population (pop) between 20 and 50 million in the year 1972, and a life expectancy (lifeExp) greater than 60 years
Hint:
Filter the year column by selecting 1972.
Use a filter on the pop column with the condition Between 20,000,000 and 50,000,000.
Then filter the lifeExp column with the condition Greater than 60.
6. Which countries in the Americas had a consistently increasing life expectancy (lifeExp) from 1962 to 1987?
Hint:
Filter the continent column by selecting Americas.
Set a filter on the year column to select the range 1962–1987.
Look for countries where the lifeExp value increases continuously over this period.
7. Find countries in the year 2007 with a GDP per capita (gdpPercap) greater than $20,000 and a population (pop) of less than 1 million
Hint:
Filter the year column by selecting 2007.
Use a filter on the gdpPercap column with the condition Greater than 20000.
Use a filter on the pop column with the condition Less than 1,000,000.
8. Which countries in Asia had a population increase of more than 50% between 1952 and 2007?
Hint:
Filter the continent column by selecting Asia.
View the population values for the years 1952 and 2007.
Calculate the percentage increase and filter for countries with more than a 50% increase.
9. In which years did countries from Oceania have a life expectancy (lifeExp) below 65 years?
Hint:
Filter the continent column by selecting Oceania.
Use a filter on the lifeExp column with the condition Less than 65.
Check the year column to identify the years that match the condition.
10. Which countries in Africa had a GDP per capita (gdpPercap) between $5,000 and $10,000 in the year 1977?
Hint:
Filter the year column by selecting 1977.
Filter the continent column by selecting Africa.
Use a filter on the gdpPercap column with the condition Between 5000 and 10000.