BW #18: World population

What is the most populous country in the world? As of recently, it's India, not China. This week, we dive into UN population figures to understand world population statistics and trends.

Growing up in the US, I knew that I lived in a pretty big country, in at least two senses of the word: The US had a large population, and it was also spread out over a large area.

But of course, we were often reminded that two other countries were even larger than the US, at least in population: China, the most populous country in the world, and India, which also had a huge population, even if not as large as China. And indeed, the notion of China as the largest country in the world has been etched in our minds for decades. Even on my numerous visits to China, it was common to hear people say, "China has a lot of people" when complaining about traffic, crowded tourist sites, or the difficulty of getting a spot at a good university.

It was thus big news when, several weeks ago, it was announced that India, not China, is the most populous country in the world. This was based on data that the UN collects about various countries, mixed with forward-looking projections based on trends that they've seen.

This week, we'll look at the UN's world population data. We'll look at the largest countries, we'll look forward at some projections, and we'll see what some of the causes might be for those trends.

Data and questions

The data this week comes from the United Nations Department of Economic and Social Affairs, Population Division. (I'm always amazed and amused by how many departments, divisions, and subdivisions a large bureaucracy can have.) The main data comes from their page at https://population.un.org/wpp/Download/Standard/CSV/.

The population information and projections are all in a CSV file you can download from:

https://population.un.org/wpp/Download/Files/1_Indicators%20(Standard)/CSV_FILES/WPP2022_Demographic_Indicators_Medium.zip

However, the UN describes locations using ISO 3166 (https://en.wikipedia.org/wiki/ISO_3166-1), a standard for countries, regions, and the like. You can get those ISO codes on GitHub at

https://github.com/lukes/ISO-3166-Countries-with-Regional-Codes

Or if you prefer to get the raw CSV data, you can get it from here:

https://raw.githubusercontent.com/lukes/ISO-3166-Countries-with-Regional-Codes/master/all/all.csv

And now, onto some questions!

  • Retrieve the UN population data and projections, and put it into a data frame.
  • Create a line plot showing the total world population (where "LocTypeName" is "World") across all years, including future projections. The x axis should be years, and the y axis should be population.