From loop to purrr
The first instinct for many R users (especially those coming from other programming languages) is to use run of the mill for loop: This works fine. It loops through country_1 to country_8, checks if each column exists, and converts the country names into COW codes. Buuut there’s another way to do this. Enter purrr and…
Graphing female politicians in Irish parliament with R PART 2: Trends and Maps
Packages we will need In PART 1, we looked at the gender package to help count the number of women in the 33rd Irish Parliament. I repeated that for every session since 1921. The first and second Dail are special in Ireland as they are technically pre-partition. Cleaned up the data aaaand now we have…
How to download and graph interactive country maps in R
Packages we will be using: In this blog, we will make maps! Mapppsss!!! Go to this website and find the country GeoJSON you want to download: We can choose the country we want. For example, Ireland Or South Korea, maybe~ Click the blue button to download the file. I saved it on my desktop so…
Graphing female politicians in Irish parliament R PART 1: Predicting names
Packages we will be using: I heard a statistic a while ago that there are more men named Mike than total women in charge of committees in the US Senate. In this blog, we can whether the number of women in the Irish parliament outnumber any common male name. A quick glance on the most…
How to web scrape and graph 2024 Irish election data with R
Packages we will use: I am an Irish person living abroad. I did NOT follow the elections last year. So, as penance (as I just mentioned, I am Irish and therefore full of phantom Catholic guilt for neglecting political news back home), we will be graphing some of the election data and familiarise ourselves with…
How to use parallel processing to speed up executing large / complex models in R
Packages we will need: In this blog, we look at a few lines of code that help us run multiple models with panel data more quickly with parallel processing. We can use the Varieties of Democracy (V-DEM) package to download our data! Click here to read more about downloading V-DEM data from the vdemdata package…
How to automate panel data modelling with dynamic formulas in R
Packages we will need: When I am running a bunch of regressions, I can get bogged down with lines and lines of code. As a result, it is annoying if I want to change just one part of the formula. This means I have to go to EACH model and change the variable (or year…
How to improve graphs with themes and palettes: Top packages in R
In this blog, we can look at ways to make our plots and graphs more appealing to the eye. Before we go about working on the aesthetics, let’s build and save a typical political science graph. We will examine the inverted U shape between democracy and level of mass mobilization across six different regions. The…
How to download and animate the Varieties of Democracy (V-DEM) dataset in R
In this blog post, we will download the V-DEM datasets with their vdemdata package. It is still in development, so we will use the install_github() function from the devtools package And really quickly we can download the dataset with one line of code We can use the find_var function to get information on variables based…
Tips and code snippets to improve ggplot graphs and plots in R
Some code snippets to improve graph appearance and readability! Compare the first basic graph with the second more informative graph. Dealing with the z and y axes can be a pain. In this code: The breaks argument of scale_y_continuous() is set using a custom function that takes limits as input (which represents the range of…
Something went wrong. Please refresh the page and/or try again.
Follow My Blog
Get new content delivered directly to your inbox.