Home

Create density plots with ggridges package in R

Packages we will need: We will plot out the favourability opinion polls for the three main political parties in Ireland from 2016 to 2020. Data comes from Louwerse and Müller (2020) Before we dive into the ggridges plotting, we have a little data cleaning to do. First, we extract the last four “characters” from the … Continue reading Create density plots with ggridges package in R

Comparing mean values across OECD countries with ggplot

Packages we will need: I came across code for this graph by Tanya Shapiro on her github for #TidyTuesday. Her graph compares Dr. Who actors and their average audience rating across their run as the Doctor on the show. So I have very liberally copied her code for my plot on OECD countries. That is … Continue reading Comparing mean values across OECD countries with ggplot

Graphing Pew survey responses with ggplot in R

Packages we will need: We are going to look at a few questions from the 2019 US Pew survey on relations with foreign countries. Data can be found by following this link: We are going to make bar charts to plot out responses to the question asked to American participaints: Should the US cooperate more … Continue reading Graphing Pew survey responses with ggplot in R

Lollipop plots with ggplot2 in R

Packages we will need: We will plot out a lollipop plot to compare EU countries on their level of income inequality, measured by the Gini coefficient. A Gini coefficient of zero expresses perfect equality, where all values are the same (e.g. where everyone has the same income). A Gini coefficient of one (or 100%) expresses … Continue reading Lollipop plots with ggplot2 in R

Replicating Eurostat graphs in R

Packages we will need: In this blog, we will try to replicate this graph from Eurostat! It compares all European countries on their Digitical Intensity Index scores in 2020. This measures the use of different digital technologies by enterprises. The higher the score, the higher the digital intensity of the enterprise, ranging from very low … Continue reading Replicating Eurostat graphs in R

Bump charts for ranking with ggbump package in R

Click here for Part 1 and here for Part 2 of the series on Eurostat data – explains how to download and visualise the Eurostat data In this blog, we will look at government expenditure of the European Union! Part 1 will go into detail about downloading Eurostat data with their package. Some quick data … Continue reading Bump charts for ranking with ggbump package in R

Visualize EU data with Eurostat package in R: Part 2 (with maps)

In this post, we will map prison populations as a percentage of total populations in Europe with Eurostat data. Click here to read Part 1 about downloading Eurostat data. Next we will download map data with the rnaturalearth package. Click here to read more about using this package. We only want to zoom in on … Continue reading Visualize EU data with Eurostat package in R: Part 2 (with maps)

Download EU data with Eurostat package in R: Part 1 (with pyramid graphs)

Eurostat is the statistical office of the EU. It publishes statistics and indicators that enable comparisons between countries and regions. With the eurostat package, we can visualise some data from the EU and compare countries. In this blog, we will create a pyramid graph and a Statista-style bar chart. First, we use the get_eurostat_toc() function to … Continue reading Download EU data with Eurostat package in R: Part 1 (with pyramid graphs)

Alternatives to pie charts: coxcomb and waffle charts

Packages we will need If we want to convey nuance in the data, sometimes that information is lost if we display many groups in a pie chart. According to Bernard Marr, our brains are used to equal slices when we think of fractions of a whole. When the slices aren’t equal, as often is the … Continue reading Alternatives to pie charts: coxcomb and waffle charts

Building a dataset for political science analysis in R, PART 2

Packages we will need The main workhorse of this blog is the peacesciencer package by Stephen Miller! The package will create both dyad datasets and state datasets with all sovereign countries. Thank you Mr Miller! There are heaps of options and variables to add. Go to the page to read about them all in detail. … Continue reading Building a dataset for political science analysis in R, PART 2

Building a dataset for political science analysis in R, PART 1

When you want to create a dataset for large-n political science analysis from scratch, it can get muddled fast. Some tips I have found helpful to create clean data ready for panel data analysis. Click here for PART 2 to create dyad-year and state-year variables with conflict, geographic features and alliance data from Correlates of … Continue reading Building a dataset for political science analysis in R, PART 1

Compare Irish census years with compareBars and csodata package in R

Packages we will need: First, let’s download population data from the Irish census with the Central Statistics Office (CSO) API package, developed by Conor Crowley. You can search for the data you want to analyse via R or you can go to the CSO website and browse around the site. I prefer looking through the … Continue reading Compare Irish census years with compareBars and csodata package in R

Graph linear model plots with sjPlots in R

This blog post will look at the plot_model() function from the sjPlot package. This plot can help simply visualise the coefficients in a model. Packages we need: We can look at variables that are related to citizens’ access to public services. This dependent variable measures equal access access to basic public services, such as access … Continue reading Graph linear model plots with sjPlots in R

Examining speeches from the UN Security Council Part 1

Let’s look at how many speeches took place at the UN Security Council every year from 1995 until 2019. I want to only look at countries, not organisations. So a quick way to do that is to add a variable to indicate whether the speaker variable has an ISO code. Only countries have ISO codes, … Continue reading Examining speeches from the UN Security Council Part 1

Improve your visualizations with ggsave in R

When we save our plots and graphs in R, we can use the ggsave() function and specify the type, size and look of the file. We are going to look two features in particular: anti-aliasing lines with the Cairo package and creating transparent backgrounds. Make your graph background transparent First, let’s create a pie chart … Continue reading Improve your visualizations with ggsave in R

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 … 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 … Continue reading Add weights to survey data with survey package in R: Part 2

Add circular flags to maps and graphs with ggflags package in R

Packages we will need: Click here to add rectangular flags to graphs and click here to add rectangular flags to MAPS! Apropos of this week’s US news, we are going to graph the number of different or autocoups in South America and display that as both maps and bar charts. According to our pals at … Continue reading Add circular flags to maps and graphs with ggflags package in R