Skip to content

Instantly share code, notes, and snippets.

@diamonaj
Last active July 26, 2023 22:45
Show Gist options
  • Save diamonaj/0c2ff0a97ec87c893d11fe6f41e940d3 to your computer and use it in GitHub Desktop.
Save diamonaj/0c2ff0a97ec87c893d11fe6f41e940d3 to your computer and use it in GitHub Desktop.
###### Quiz 2 #######
# For this quiz you will analyze UN Peacekeeping data.
# At any given time, the UN is involved with many peacekeeping missions around the world.
# Almost all member-states contribute personnel to those missions. There are five types of personnel:
# experts on mission, troops, staff officers, individual police, and formed police units.
# In its efforts to involve more women in its global operations, the UN reports, monthly, the
# gender of each person sent on a mission. You can read more about it here:
# https://peacekeeping.un.org/en/women-peacekeeping
# You can access the dataset here: https://tinyurl.com/UNpckpdata
# For this assignment, you will have to load, process, analyze, and visualize the data. In the
# process you’ll also learn more about UN peacekeeping, and how a little data science applied
# to publicly-available data sets can illuminate interesting contemporary issues like global
# conflict and gender inequality.
### PRELIMINARIES
### load the data off the Internet
peacekeeping_data <- read.csv("https://tinyurl.com/UNpckpdata")
### see the first 6 rows of the data
head(peacekeeping_data)
### set all blank or missing entries to NA
peacekeeping_data[peacekeeping_data == ""] <- NA
### omit every row in the data set that contains an NA
peacekeeping_data = na.omit(peacekeeping_data)
### Change the object class of the "Last_Reporting_Date" column from character string to Date
### (you have to let R know that it's currently in "%d/%m/%Y" format)
peacekeeping_data$Last_Reporting_Date <-
as.Date(peacekeeping_data$Last_Reporting_Date, format = "%d/%m/%Y")
###### Questions
# (1) What are the dimensions of this data set?
# (2) What is the earliest date in the Last_Reporting_Date column? What is the latest date?
# (3) How many different unique entries are there in the ISOCode3 column?
# (4) How many different unique personnel types are associated with Argentina's missions?
# (5) Create a scatterplot with Male Personnel on the x axis and Female Personnel on the y axis.
# Label the axes and title the scatterplot. Write a few sentences interpreting your scatterplot.
# Use correct grammar, check spelling, etc.
### Run the following 2 lines of code:
aa <- data.frame(1:31, unique(peacekeeping_data$Contributing_Country)[1:31])
names(aa) <- c("list_of_birthdays", "list of countries")
### Now show aa, and observe it's a data frame with 2 columns.
### The first column is all the numbers from 1 to 31, and the second column are country names
aa
# (6) Identify the country associated with the date you were born (your birth month doesn't matter, only the day matters).
# For example, if you were born on Sept 5, then the date you were born is 5, and the country is Austria.
# Or, if you were born on April 1, then the date you were born is 1, and the country is Algeria.
# Examine the data associated with the country you've identified. Write a paragraph of 5-10 sentences describing this data.
# Feel free to describe it in any way you would consider useful. You are encouraged to analyze by calculating an average,
# or a median, or an interquartile range, or making comparisons of sets of numbers, etc. You are encouraged to be creative.
# Check spelling and ensure proper grammar.
# (7) Include a data visualization to accompany your paragraph, taking care to properly label it and the axes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment