Gender pay-gap in Africa

Inequality between women and men continues to exist even though it tends to improve. It can take many forms, both at the level of law and at the level of society. What about Africa? Which African countries are the least discriminatory in terms of wages between women and men? Which country has the biggest difference in pay? That is exactly what I am about to show you in this article! We will present the data and analyze them using a tool called "ggplot2". Eventually we will present the graph and draw some conclusions ;)


Step 1 : Find and upload the data

Before you can analyze data, you need to find them! Of course, I could not interviewed every country to get all the information needed. Fortunately, my friend Google helped me find this site: openAFRICA. I don’t know who is behind this project but all my congratulations to them! A site that collects open source data (accessible by all) on Africa, that’s great! In short, let’s look at the data named "Gender Pay-Gap" on their website:

> str(rawdata)
'data.frame':   36 obs. of  4 variables:
 $ country          : chr  "Algeria" "Angola" "Benin" "Botswana" ...
 $ currency.code    : chr  "DZD" "AOA" "CFA" "BWP" ...
 $ salary.usd.female: num  4624 4789 2108 15558 1365 ...
 $ salary.usd.male  : num  25319 8277 2228 17940 2077 ...

    No panic, what is important to understand here is that each line of our data has the following 4 categories:

  • the name of a country (country),
  • the currency code of that country (currency.code) : for example, the CFA for Benin,
  • the average annual wage in dollar of women in this country (salary.usd.female),
  • the average annual salary in dollar of men in this country (salary.usd.male).

Step 2 : Clean and format the data

Once you have the data upload, very often you have to clean them up. In my case I had nothing to do, the data were clean and complete! Again, all the credits goes to the website openAFRICA. Once the data are cleaned, they have to be formatted. To make my graph, I needed each line of my data to have the following properties:

  • the name of a country (country),
  • the average annual salary of a woman (male or female) in the country (salary.usd),
  • the sex of this gent (sex): M or F,
  • the difference in salary between male and female in the country (diff).

After formating the data, we get:
> str(data)
'data.frame':   70 obs. of  4 variables:
 $ country      : chr  "Algeria" "Algeria" "Angola" "Angola" ...
 $ salary.usd   : num  4624 25319 4789 8277 2108 ...
 $ diff         : num  20694 20694 3488 3488 120 ...
 $ sex          : chr  "F" "M" "F" "M" ...


Step 3 : Generate the graph

The graphic I am presenting to you right after was generated by the following code :

ggplot(data, aes(x=reorder(country, abs(diff)), y=salary.usd, fill=sex)) +
 geom_bar(stat="identity", width=.5, position = "dodge") +
 labs(title = "Ecart de rémunération en Afrique entre femmes et hommes (du plus égalitaire au moins égalitaire)\n",
      x = "Pays",
      y = "Salaire annuel (Dollar américain)",
      fill = "Sexe") +
 theme_bw() +
 theme(axis.text.x=element_text(angle=90, hjust=1, vjust=0),
       text = element_text(size=20))

The first line calls our ggplot() tool and says:

  • my data is in "data"
  • put in the x-axis the African countries, classified from the least to the most discriminatory (x=reorder(country, abs(diff))),
  • put in the y-axis the salaries (y=salary.usd),
  • put a different color depending on the sex (fill = "Sexe")..

The second line tells our tool that we want to generate a stick diagram. The line that follows specifies the title of the graph, the name of each axis and the title of the legend. The last two lines serve to do a little formatting, define a style to the graph. With these few lines of code, we get this:


Looking at this diagram, we can see that Liberia, Benin and Mozambique are in order, the top 3 of African countries where women and men have almost the same salary! On the other hand, the countries most affected by a great difference in wages between women and men are Algeria, Mauritius and Tunisia! One thing is to have as little inequality as possible between women and men, another thing is to make a good living. And according to the data from openAFRICA, the country where women earn the most is Botswana, the equivalent being Mauritius for men. So, ladies and gentlemen, what country are you going to move to soon (laughs)?

Writing : Alexandre Gbaguidi Aïsse
Translation : Tania Agbaholou

Who am I?

My name is Alexandre Gbaguidi Aïsse, half beninese, half russian and my life can be summed up in two words: computing and music. Graduate of EPITA, an engineering school, I currently work for Bentley Systems as a software engineer. In my spare time, either I do or listen to music.

Leave a comment

Comments (3)

  1. Toutes mes excuses aux Gabonais qui sont absents de notre diagramme. Il semble que le site openAFRICA n'aie pu obtenir les données de tous les pays.

    by Shumpaga at 16:07, Feb. 10, 2019

  2. Premier commentaire encore !!! J suis imbattable. Skuuuuur

    by ZEF at 16:09, Feb. 10, 2019

  3. ZEF, regarde bien haha :)

    by Shumpaga at 16:10, Feb. 10, 2019