-
Notifications
You must be signed in to change notification settings - Fork 46
/
WiP-Tidy-Data-dt-Exercise.Rmd
125 lines (83 loc) · 3.62 KB
/
WiP-Tidy-Data-dt-Exercise.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
---
title: "Women in Parliament - Tidy Data"
author: "Your Name Here"
date: "`r format(Sys.time(), '%a %d %b %Y (%H:%M:%S)')`"
output:
html_document:
highlight: tango
theme: united
toc: yes
toc_depth: 3
toc_float:
collapsed: no
smooth_scroll: no
pdf_document:
toc: yes
toc_depth: '3'
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(here)
```
```{r imageStart, echo=FALSE, out.width="20%"}
knitr::include_graphics("images/Women_in_Parliament_hex.svg")
```
# Objectives
*Explore the geographical and time trends for the percentage of women in
national parliaments.*
# Understanding the Data
## The World Bank Data
The raw data for *"Proportion of seats held by women in national parliaments"*
includes the percentage of women in parliament (_"single or lower parliamentary chambers
only"_) by country (region) and year. It can be downloaded from:
- https://data.worldbank.org/indicator/SG.GEN.PARL.ZS
As part of its "open data" mission the World Bank offers _"free and open access
to global development data"_ kindly licensed under the "Creative Commons Attribution
4.0 (CC-BY 4.0)".
## Source Data
The data originates from the "Inter-Parliamentary Union" (IPU)[^ipuwebsite] which
provides an *_"Archive of statistical data on the percentage of women in
national parliaments"_* going back to 1997 on a monthly basis:
- http://archive.ipu.org/wmn-e/classif-arc.htm
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).
## Data limitations
Take caution when interpreting these data, as parliamentary systems vary from country
to country, and in some cases over time. Some of the issues to consider include:
- Who has, and who does not have, the right to become a Member of Parliament (MP)?
- How does someone become an MP? Through democratic elections? How is "democratic
election" defined?
- What is the real power of MPs and their parliament? Can MPs make a difference?
## Data definitions & assumptions
### "Women"
The definition for “women” is not given, so we will assume that it refers to a
binary classification for gender (sex).
### "Country (Region)"
The definition of countries and regions can change over time. (e.g. formation of new
countries after conflicts, new member states joining a pre-existing collective).
How are these changes reflected in the data? How do they affect the interpretation?
## Pro tip
Understand the limitations of your data before anybody else points them out to you.
# About the data file
The data is stored in a file called: ``r list.files(path = here("data"), pattern = "^API")``
To simplify things we have copied it to `WB-WiP.csv` (which also allows us to
maintain the original file in case something goes wrong).
## Pro tip
Always keep a backup copy of the data. Alternatively, set the data file(s) to
“read-only” to protect it from being overwritten or modified.
# Importing the data
Based on our findings above, we can "skip" the first four lines and treat the
fifth line as column (variable) names. Also note the use of the `check.names`
argument to ensure that the column names are compliant in R.
```{r readData, collapse=TRUE}
library(data.table)
library(here)
wip <- fread(here("data", "WB-WiP.csv"),
skip = 4, header = TRUE,
check.names = TRUE)
```
# Continue from here...
```{r imageEnd, echo=FALSE, out.width="60%"}
knitr::include_graphics("images/Women_in_Parliament_rect.svg")
```