-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathassignment-1.Rmd
123 lines (85 loc) · 3.71 KB
/
assignment-1.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
---
title: "Assignment 1 - The tidyverse"
author: "FILL IN YOUR FULL NAME"
date: "`r format(Sys.time(), '%B %d, %Y | %H:%M:%S | %Z')`"
output:
html_document:
code_folding: show
df_print: paged
highlight: tango
number_sections: no
theme: cosmo
toc: no
---
<style>
div.answer {background-color:#f3f0ff; border-radius: 5px; padding: 20px;}
</style>
```{r, include=FALSE}
knitr::opts_chunk$set(echo = TRUE,
eval = TRUE,
error = FALSE,
message = FALSE,
warning = FALSE,
comment = NA)
```
<!-- Do not forget to input your Github username in the YAML configuration up there -->
***
```{r, include = T}
# LOAD THE PACKAGES YOU ARE USING IN THIS CODE CHUNK library(nameofpackage)
```
<br>
### Getting started with the Comparative Legislators Database
The Comparative Legislators Database (CLD) includes political, sociodemographic, career, online presence, public attention, and visual information for over 45,000 contemporary and historical politicians from ten countries (see the [corresponding article](https://www.cambridge.org/core/journals/british-journal-of-political-science/article/comparative-legislators-database/D28BB58A8B2C08C8593DB741F42C18B2) for more information). It can be accessed via `legislatoR` - an R package that is available on both [CRAN](https://cran.r-project.org/web/packages/legislatoR/index.html) and [GitHub](https://github.com/saschagobel/legislatoR).
Before you start with the following tasks, skim the tutorial to make yourself familiar with the database. You find it [here](https://cran.r-project.org/web/packages/legislatoR/vignettes/legislatoR.html).
For the following tasks, you will work with ONE of the legislatures. The legislature you'll work with depends on your first name:
| Your first name starts with... | Legislature | Code |
|---------|-------|-------|
| A-C | Austrian Nationalrat | `aut` |
| D-F | Canadian House of Commons | `can` |
| G-I | Czech Poslanecka Snemovna | `cze` |
| J-L | Spanish Congreso de los Diputados | `esp` |
| M-O | French Assemblée | `fra` |
| P-R | German Bundestag | `deu` |
| S-U | Irish Dail | `irl` |
| V-X | UK House of Commons | `gbr` |
| Y-Z | US House of Representatives | `usa_house` |
The following tasks will be based on data from the `core` and `political` tables of the database.
<br>
***
### Task 1 - Descriptives [8 points in total]
a) What's the overall share of male legislators in the entire dataset? [1 point]
```{r}
# YOUR CODE HERE
```
b) How many (both in absolute and relative terms) legislators died in the same place they were born in? [1 point]
```{r}
# YOUR CODE HERE
```
c) Create a new variable `age_at_death` that reports the age at which legislators died. Then, plot the distribution of that variable for the entire dataset. [2 points]
```{r}
# YOUR CODE HERE
```
d) What is the most frequent birthday in your sample (e.g., “January 15")? [2 points]
```{r}
# YOUR CODE HERE
```
e) Generate a table that provides the 5 legislators with the longest names (in terms of number of characters, ignoring whitespace). [2 points]
```{r}
# YOUR CODE HERE
```
<br>
***
### Task 2 - Exploring trends in the data [8 points in total]
a) Using data from all sessions, provide a plot that shows the share of male legislators by session! [3 points]
```{r}
# YOUR CODE HERE
```
b) Explore another relation of variables in the dataset. Your analysis should (i) use data from both the `core` and the `political` table and (ii) feature data from several sessions. Also, offer a brief description and interpretation of your findings! [5 points]
```{r}
# YOUR CODE HERE
```
<div class = "answer">
YOUR ANSWER SHOULD GO HERE
</div>
<br>
***