library(tidyverse)
library(wbstats)
library(vdemdata)
library(countrycode)Coding Assignment 1
Wrangling Data
Overview
For this assignment, you are going to download some variables using the wbstats and vdemdata packages. Then you are going to wrangle these data and merge the two data sets into one and analyze how they relate to women’s representation in national parliaments. Do your work for each step in the code chunks provided. Be sure to label your code chunks.
Here is a setup code chunk. You can load all of your packages here or as you go along in the code chunks below using the library() function. However, note that you really only need to load a library once per document.
Please refrain from installing any packages in your code chunks because this will also install them every time the code chunk is run or your document is rendered. This may not be desirable for you or whoever is looking at or running your code (e.g. me).
Step 1: Download data from V-Dem (20pts)
Look at the V-Dem codebook. Identify two measures of democracy that are not the polyarchy score that we used in Module 1.2.
Try to pick variables that will relate to women’s representation and read the description of the variable to make sure that it includes data for a sufficient number of years, e.g. that the data will be somewhat recent. Select the most recent 20 years of data for your analysis.
Use glimpse() or View() to make sure that the data downloaded properly.
democracy <- vdem |>
filter(____) |>
select(
country = country_name,
year,
____ = ____, # new name = old name
____ = ____
)
glimpse(____)Step 2: Download data from the World Bank (20 pts)
Next, download the variable on women’s represenation that we used in Module 1.2 (“SG.GEN.PARL.ZS”) and at least one additional measure related to women’s empowerment. Go to the WDI site the wb_search() function to identify relevant variables. Download the most recent 20 years of data for your analysis.
Try to make sure you download indicators with enough data to conduct your analysis. You won’t get great results if there are too many NAs.
women_emp <- wb_data(
indicator = c("SG.GEN.PARL.ZS", "____"),
mrv = ____
)
glimpse(____)Step 3: Merge the data (20 pts)
Now add country codes using the countrycode package and merge the data using left_join().
democracy <- democracy |>
mutate(iso3c = countrycode(
sourcevar = ____,
origin = "____",
destination = "____"
))
dem_women <- left_join(____, ____, by = ____)
glimpse(____)Step 4: Summarize your combined data set (20 pts)
Use group_by(), summarize() and arrange() to glean insights about your data. For example, how do regions compare on mean values of women’s representation and how do these values relate to the values of other variables in your data set? Which countries stand out in terms of women’s representation? Etc.
Step 5: Interpret your data (20 pts)
Write a paragraph or so relating your insights to the Norris reading about electoral reform and women’s representation. Picking a handful of country cases from your data, how does your analysis relate to her arguments about the relevance of electoral systems, statutory quotas, reserved seats or voluntary quotas?
Don’t write your paragraphs or any interpretation or analysis in a code chunk. Use markdown text. Quarto is designed to be a literate programming tool, so you can write your analysis in markdown text and include code chunks when necessary to support your argument.
Render your document to HTML, then zip your entire project folder and submit it to Blackboard. You can work locally or on Posit Cloud. Either way, make sure the rendered HTML is included in the folder before zipping.
Before submitting, feel free to delete any of the callout boxes in this document. Doing so will make your final document more legible and signals that you have read the instructions. You are also welcome to choose a different Quarto theme or apply other styling options in the YAML header to personalize your document.