Is the sum of value added by all resident producers plus any product taxes (less subsidies) not included in the valuation of output plus net receipts of primary income (compensation of employees and property income) from abroad.
All data are in current U.S. dollars.
Source
All data is from the World Bank and uses a Creative Commons licence. Current at 2021-06-27. Data is found here:
Read the raw data from World Bank. We replace .. with NA as this is easier to work with in R and remove Series Name and Series Code columns, as we will not need these.
We see from the str() that this data is in a wide format, with ‘strange’ year column names.
Tidy the Data
To work best in R, we should use a long table format - giving one observation per row.
Here, we:
rename the nnnn [YRnnnn] columns to nnnn
remove all spaces in column names
pivot the data to create year and gni values columns, each row having one one year per country
Select Countries
We’re not doing anything major here, just being curious, so just work with a few countries.
Plot GNI Data
A plot of GNI in current United States Dollars (USD).
The vertical line represents the year 2008, when the “global financial crisis” occurred.
It is interesting to see that it actually helped Japan and (apart from a quick, small fall) Australia.
The United Kingdom fared the worse, but appears to have been in decline before the event.
The United States only flattened out.
Zooming out to the World data, there clearly is a dip in GNI, but also in approx. 2015 which can also be seen in the chosen country charts.
Percentage Change
Perhaps a “fairer” approach for comparison, is to compare the percentage increase since the first observed year.
This code will select the minimum year and create a new column (first) containing that data for each country.
Join our first observation data to the original GNI data.
Also create a percent column which takes each GNI observation and creates a percentage increase since the first observation…
… and plot.
This now clearly shows almost all seemed to suffer during the late 1970s into early 1980s (including the “winter of discontent”).
Fun Stats
Biggest Increase
So it seems that Qatar has and increase of 55,261.22% in 2014.
Let’s plot it.
WOW! ‘Something’ happened in about 2001, which led to exponential increases each year. Even Qatar didn’t escape the 2008 financial crises, nor the losses in 2015 (see above) - which occur the year after the highest GNI.
Getting Percent Increase Each Year
Hmmmm….
Gosh - We Need a Map!
Normally, you may want to take population into account when displaying the “value” of a country. I don’t intend to do that here, so this is one of many, many approaches that could be used to demonstrate the distribution of wealth around the world.
Randomly, I’m selecting 2019 data. Most countries should have a value (for the interested reader to confirm if this is true!); and the value will not be impacted by the Covid-19 global epidemic.
Arrange World Data and Create Map Data
In this code, we obtain a range (I’m sure this can be done ‘automatically’, but enough for now!). Dividing into 8 groups, each group has 28/9 countries - each being within the same range of GNI. On another project, we could first remove the regions (groups of countries) that are in the data, which may skew the result…
We manually create the list of breaks and labels, based on the result.
… 9 groups, because that is the max number of colours in the brewer sequential colour palette!