Site icon R-bloggers

Change in life expectancy animated with geo charts

[This article was first published on mages' blog, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The data of the World Bank is absolutely amazing. I had said this before, but their updated iPhone App gives me a reason to return to this topic. Version 3 of the DataFinder App allows you to visualise the data on your phone, including motion maps, see the screen shot below.

Screen shot of DataFinder 3.0

I was intrigued by the by the changes in life expectancy over time around the world. The average life expectancy of a new born baby in 1960 was only 52.6 years, and don’t forget we are in 2012, 52 years later. Babies born in 2009 can expect to live to the age 69.4 years, an increase by nearly 17 years or 32%. That is remarkable. But these are average figures and vary a lot by country.

The world bank’s online version of the map unfortunately lacks the the animation of the smartphone app. Thus I was keen to find out if I could reproduce something similar in R based on code and ideas provided to me by Manoj Ananthapadmanabhan and Anand Ramalingam last year. Those ideas had helped me to create the animated geo maps demo “AnimatedGeoMap” of the googleVis R package.

Here is the result using the R packages WDI and googleVis. You find a table with the mapping between country code and name, and the R code below.

Life expectancy at birth between 1960 and 2009


< !--






Ideally the chart would have a time line at the bottom which would allow the user to move between the years, similar to the feature in motion charts. I am sure with a bit of JavaScript magic this would be possible, but unfortunately I am not a magician.

–>

The animated geo chart reveals some interesting features. I noticed the increase in life expectancy in China, Northern Africa and the Middle East, Latin America and the Western World, while the Sub-Saharan African countries and Afghanistan stay behind. But it is difficult to follow the movements over time. Maybe an animated map isn’t the best visualisation after all. So let’s add a chart which looks at the difference in life expectancy between 2009 and 1960.

Differences in life expectancy at birth between 2009 and 1960


The picture becomes much clearer and the two charts together provide some interesting stories.

Only Zimbabwe and Ukraine have seen a reduction in life expectancy. Sadly I am not surprised to see Zimbabwe here, but I am surprised about Ukraine. Wikipedia explains that Ukraine suffers a high mortality rate from environmental pollution, poor diets, widespread smoking, extensive alcoholism, and deteriorating medical care. Unfortunately it doesn’t look much better for its neighbour. Russia hasn’t developed very much either over the last 50 years. The Russian’s life expectancy moved only from 67.4 years in 1960 to 68.6 in 2009 (below the World average), and was as low as 65 in 2005.

In the same time period other countries added nearly 30 years to their life expectancy. Most remarkable is the improvement in China from 43.5 in 1960 to 73.1 years in 2009, now on par with Sweden in 1960. Yet I believe that the figures for China are low in the early 1960s due to the great famine which took place between 1958 and 1961. Also Vietnam has seen an increase by 30 years to 75 by 2009. And while the North Korean population lives now 13 years longer to the age of 68, their South Korean neighbours added 27 years over the same period and can expect to live 12 years longer than North Koreans. The following tables provides some summary statistics.


What about the overall trend and distribution of life expectancy over time?

Distribution of life expectancy between 2009 and 1960


The above chart shows the quantiles of life expectancy weighted by population from 1960 to 2009. The overall trend is positive and the gap between the countries has narrowed over time. The countries with the lowest life expectancy have been those which experienced war, terror, genocide and draught: Afghanistan, Cambodia, East-Timor, Rwanda, Mali and Guinea.

Does the positive trend then suggest that the world has become more peaceful over the years?
The data available from the Department of Peace and Conflict Research of Uppsala University doesn’t support this argument particularly. The number of armed conflicts increased since the end of World War II until 1994 and only then the trend started to reverse.


By the way, like the World Bank, the guys from Uppsala created an iPhone App for their data. Amazing!

If you are now interested about your own life expectancy then check it out on Wolfram Alpha and add your country, age and gender to the query.

R code

To leave a comment for the author, please follow the link and comment on their blog: mages' blog.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.