# clean v-dem data
Coding Assignment 2
Overview
For this assignment, you are going to download some variables using the wbstats
and vdemlite
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.
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 (10pts)
Use the V-Dem codebook or the searchdem()
function in vdemlite
to identify at least two measures of women’s empowerment (make at least one something that we did not use in class). Also retrieve the six-fold regional classification that we used in class and a general measure of democracy (like the polyarchy or libdem score). Now use fetchdem()
to download the most recent 25 years or so of data for your analysis for all countries in the dataset. Make sure to load the packages that you need and glimpse()
the data or View()
it to make sure that it downloaded properly.
Step 2: Download data from the World Bank (10 pts)
Next, download the variable on women’s representation that we used in Module 1.2 (“SG.GEN.PARL.ZS”), at least one additional measure related to women’s empowerment and a measure of wealth (GDP per capita). Go to the WDI site the wb_search() function to identify relevant variables. Download data for the same time period as you did for the V-Dem data for all countries. Ensure that at least one of the variables you select is different from the ones we explored in class.
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.
Step 3: Clean the data (20 pts)
Now clean the data. Drop any columns that you will not need for the analysis. Filter out any years that do not match between the two data frames. Transform the region codes into actual region names. Etc.
# clean wb data
Step 4: Merge the data (20 pts)
Now add country codes using the countrycode
package and merge the data using left_join()
.
Step 5: Summarize your combined data set (20 pts)
Use group_by()
, summarize()
and arrange()
to glean preliminary 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?
# Regional summary
# Country summary
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.
Step 6: Visualize and interpret your data (20 pts)
Using the data from step 5, create an appropriate visualization that either shows differences in levels of women’s empowerment across countries or regions or demonstrates the relationship between women’s empowerment and a potential explanatory variable like welath or democracy. Then write a few lines about the patterns that your visualization uncovers. (Note that you will need to store the summary that you created in Step 5 as an object in order to do this.)
You can relate your analysis to the assigned Norris reading that explores reasons for variations in women’s empowerment but this is not required.
Extra Credit (3 pts.)
Sometimes our data does not come in the format that we need to have it in for our analysis. Demonstrate that you know how to pivot data from wide to long form using the world_bank_pop
data frame that comes with the tidyr
package. Then pivot again (wider this time) to get the data into tidy format.
Now render the document to make sure everything runs and to produce a final HTML document!
Submission
After rendering your document, export your project folder and submit it on Blackboard. You will find the link to the Coding Assignment one submission portal under the Assignments link. There is a screen capture video in the Discord server that will help you understand how to do this.
Deadline Extension
I am going to be moving this weekend and may not be able to respond to questions right away (I may not even have an internet connection). Therefore I am extending the deadline to Tuesday, March 4 at 11:59 PM.