This blog post will look at the plot_model() function from the sjPlot package which can help visualise the coefficients in a model in a plot. Packages we need: We can look at variables that are related to the extent to which citizens’ access to state public services is equally distributed across socio-economic groups. The variable measures equal access access to basic public services, such as … Continue reading Graph linear model plots with sjPlots 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
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
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
Packages we will need: One core assumption of linear regression analysis is that the residuals of the regression are normally distributed. When the normality assumption is violated, interpretation and inferences may not be reliable or not at all valid. So it is important we check this assumption is not violated. As well residuals being normal distributed, we must also check that the residuals have the … Continue reading Check linear regression residuals are normally distributed with olsrr package in R.