This post is a quickie to show how we can visualize the UK election results with just a few lines of R code. (Really, very few). 1 We can load in our usual tidyverse tools, along with a handy little data package, parlitools. library(readr) library(dplyr) library(ggplot2) library(parlitools) library(sf) Thanks to this R Bloggers post, we have the data (the UK Electoral Commission must have it up by now anyway), so
This article by Mike Holly on Mises.org interested me. I wasn’t aware of the history of healthcare costs in the US, and it’s quite surprising, especially the take-off in costs after the 1960s. Holly’s argument is that the “U.S. ‘health care cost crisis’ didn’t start until 1965. The government increased demand with the passage of Medicare and Medicaid while restricting the supply of doctors and hospitals.” In fact, I was quite impressed with this graph: x <- c("rvest", "dplyr", "tidyr", "ggplot2", "magrittr", "lubridate") lapply(x, require, character.only = TRUE) I’ve wanted an excuse to use Google’s CausalImpact package for a while now, so let’s give it a shot using these data.
This Guardian article on the prospective French President Macron got me thinking, especially this passage: France’s economic performance in recent years has been underwhelming, especially when compared to that of Germany. Fifteen years ago, the eurozone’s two biggest countries enjoyed comparable living standards. Today, Germany’s are almost a fifth higher than those in France. Likewise, at the time when euro notes and coins were introduced in 2002, French and German unemployment rates were both around 8%.
From time to time, you might need to copy and paste something into R and turn it into a character string. Maybe it’s something from the output of an error message, or from someone else’s malformed data, or something copied from a document or the internet. If it’s something small, then it’s usually OK to just manually insert "" around the strings and , between them. For something large, that’s just a nightmare.
I was just about to update R a while ago when I thought to myself that there must be a way to do this inside of R (RStudio, I mean). A quick Google search brought me to the installr package. Very nice, but I use a Mac. Hmmm… A bit more searching and I found Andrea Cirillo’s updateR package, which was made for OS X, fantastic. I tried it out, and although it worked great, I still had to leave RStudio to check to see if the latest version installed.
This week I was working with some RSS feeds in R. You can parse these feeds directly with packages like XML or xml2, or use the rss package (not on CRAN) or the feedeR package (on CRAN). However, I noticed that both rss and feedeR return lists, which necessitates further work in R to get the data into a tidy format, and that both packages leave interesting data behind. With that in mind, I decided to make tidyRSS, a package for parsing these feeds and returning a tidy data frame to the user.
Brazil, where I live, has a shockingly high murder rate. I mean, it’s freaking astounding. A recent blog I read (see it here) caused a bit of discussion among some friends of mine on facebook. Is Brazil a failed state? The obvious answer seems ‘no’, but then again, isn’t security one of the basic functions of the state? Just how bad is it with regard to murders in Brazil? (Pretty nuts is the answer.) We can visualize this is in R to get some idea of how nuts it is.
I really like this image by Tom Burns.1 The liberal2 in me appreciates making cheap fun of people who were horribly mistaken (Lenin; Marx, although I don’t mean to slight his contributions to social science), scum like Stalin, and Fidel Castro, who might have started out with a laudable takedown of a corrupt dictator, but who then became…a corrupt dictator, of course. The artist in me just loves the awesome colours.
Update: for some people who may have some issues setting up the blog the way I’ve set out here, see Kate’s helpful comments below. Since April or so of last year, I’ve had a personal website on GitHub pages, where I keep this blog and a few other things. Setting it up was at times frustrating, but a good learning process (I especially picked up a lot of Git through that experience).