GithubHelp home page GithubHelp logo

corriebar / women-in-parliament-hex-sticker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from saghirb/women-in-parliament-hex-sticker

0.0 1.0 0.0 769 KB

Women in Parliament Hex Sticker

License: Other

women-in-parliament-hex-sticker's Introduction

Women in Parliament Hex Sticker & Data

Are you bored with using the R iris, mtcars, ... datasets?

Then use the "Women in Parliament" data from the World Bank instead!. Great for teaching, learning, presentations or reprex. It has a hex sticker too!

Women in Parliament Hex Sticker

Women in Parliament Hex Sticker

Download: PNG (754x873) or SVG.

Bonus Image

Women in Parliament Bonus Image

Download: PNG (3508x2480) or SVG.


World Bank "Women in Parliament" Data

The raw data for "Proportion of seats held by women in national parliaments" ("single or lower parliamentary chambers only") by can be directly downloaded from:

As part of its "open data" mission the World Bank kindly offers "free and open access to global development data" licensed under the "Creative Commons Attribution 4.0 (CC-BY 4.0)".

Source Data

The data originates from the "Inter-Parliamentary Union" (IPU) which provides an "Archive of statistical data on the percentage of women in national parliaments" going back to 1997 on a monthly basis:

The World Bank data is for “single or lower parliamentary chambers only”, while the IPU also presents data for “Upper Houses or Senates”. Moreover, the IPU provides the actual numbers used to calculate the percentages (which the World Bank does not). The data has to be scraped from the IPU website (please check the robots.txt file first).


Importing the Data into R

The data can be imported into R using the wbstats package or by reading in the CSV file available from the World Bank's website.

R wbstat package

The R package wbstats provides access to World Bank's indicator data. Use the following code to get the women in parliament data:

library(wbstats)
wip <- wb(indicator = "SG.GEN.PARL.ZS") 

Importing the Raw Data into R

First download the latest CSV file from:

Below I will refer to this file as "WiP-Data.csv" but please use the actual file name that you save it as.

Using data.table

library(data.table)
wipdt <- fread("WiP-Data.csv",
               skip = 4, header = TRUE, check.names=TRUE)
WP <- melt(wipdt,
           id.vars = grep("Name|Code", names(wipdt), value = TRUE),
           measure = patterns("^X"),
           variable.name = "YearC",
           value.name = c("pctWiP"),
           na.rm = TRUE)
WP[, Year:=as.numeric(gsub("[^[:digit:].]", "",  YearC))][
   , YearC:=NULL]

Using tidyverse

library(readr)
library(dplyr)
library(tidyr)
wiptv <- read_csv("WiP-Data.csv", skip = 4) 
names(wiptv) <- make.names(names(wiptv))
wipTidy <- wiptv %>% 
    gather(key=YearC, value=pctWiP, starts_with("X"), na.rm=TRUE) %>% 
    mutate(Year = parse_number(YearC)) %>% 
    select(-YearC)

R Guides Using Women in Parliament Data

Use the following R guides to get ideas on how to teach using the women in parliament data:

Women in Parliament - data.table

Women in Parliament - tidyverse


Acknowledgements

The images were create by Marina Costa guided by Andreia Carlos and myself.

You can view Marina's great portfolio at:

Thank you Marina and Andreia as it was really nice to work with you both.

women-in-parliament-hex-sticker's People

Contributors

corriebar avatar saghirb avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.