Create a correlation matrix with GGally package in R

We can create very informative correlation matrix graphs with one function. Packages we will need: First, choose some nice hex colors. Next, we can go create a dichotomous factor variable and divide the continuous “freedom from torture scale” variable into either above the median or below the median score. It’s a crude measurement but it serves to highlight trends. Blue means the country enjoys high … Continue reading Create a correlation matrix with GGally package in R

Add weights to survey data with survey package in R: Part 2

Click here to read why need to add pspwght and pweight to the ESS data in Part 1. Packages we will need: Click here to learn how to access and download ESS round data for the thirty-ish European countries (depending on the year). So with the essurvey package, I have downloaded and cleaned up the most recent round of the ESS survey, conducted in 2018. … Continue reading Add weights to survey data with survey package in R: Part 2

BBC style graphs with bbplot package in R

Packages we will need: Click here to check out the vignette to read about all the different graphs with which you can use bbplot ! We will look at the Soft Power rankings from Portland Communications. According to Wikipedia, In politics (and particularly in international politics), soft power is the ability to attract and co-opt, rather than coerce or bribe other countries to view your … Continue reading BBC style graphs with bbplot package in R

Add weights to survey data with survey package in R: Part 1

With the European Social Survey (ESS), we will examine the different variables that are related to levels of trust in politicians across Europe in the latest round 9 (conducted in 2018). Click here for Part 2. Click here to learn about downloading ESS data into R with the essurvey package. Packages we will need: The survey package was created by Thomas Lumley, a professor from … Continue reading Add weights to survey data with survey package in R: Part 1

Add rectangular flags to maps in R

We will make a graph to map the different colonial histories of countries in South-East Asia! Click here to add circular flags. Packages we will need: I use the COLDAT Colonial Dates Dataset by Bastien Becker (2020). We will only need the first nine columns in the dataset: Next we will need to turn the dataset from wide to long with the reshape2 package: We … Continue reading Add rectangular flags to maps in R

Graph countries on the political left right spectrum

In this post, we can compare countries on the left – right political spectrum and graph the trends. In the European Social Survey, they ask respondents to indicate where they place themselves on the political spectrum with this question: “In politics people sometimes talk of ‘left’ and ‘right’. Where would you place yourself on this scale, where 0 means the left and 10 means the … Continue reading Graph countries on the political left right spectrum

Download European Social Survey data with essurvey package in R

The European Social Survey (ESS) measure attitudes in thirty-ish countries (depending on the year) across the European continent. It has been conducted every two years since 2001. The survey consists of a core module and two or more ‘rotating’ modules, on social and public trust; political interest and participation; socio-political orientations; media use; moral, political and social values; social exclusion, national, ethnic and religious allegiances; well-being, … Continue reading Download European Social Survey data with essurvey package in R

Add rectangular flags to graphs with ggimage package in R

This quick function can add rectangular flags to graphs. Click here to add circular flags with the ggflags package. The data comes from a Wikipedia table on a recent report by OECD’s Overseas Development Aid (ODA) from donor countries in 2019. Click here to read about scraping tables from Wikipedia with the rvest package in R. In order to use the geom_flag() function, we need … Continue reading Add rectangular flags to graphs with ggimage package in R

Scrape NATO defense expenditure data from Wikipedia with the rvest package in R

We can all agree that Wikipedia is often our go-to site when we want to get information quick. When we’re doing IR or Poli Sci reesarch, Wikipedia will most likely have the most up-to-date data compared to other databases on the web that can quickly become out of date. So in R, we can scrape a table from Wikipedia and turn into a database with … Continue reading Scrape NATO defense expenditure data from Wikipedia with the rvest package in R

Interpret multicollinearity tests from the mctest package in R

Packages we will need : The mctest package’s functions have many multicollinearity diagnostic tests for overall and individual multicollinearity. Additionally, the package can show which regressors may be the reason of for the collinearity problem in your model. Click here to read the CRAN PDF for all the function arguments available. So – as always – we first fit a model. Given the amount of … Continue reading Interpret multicollinearity tests from the mctest package in R