## Carnaval!

A Shiny app to find Carnaval blocos in São Paulo

8 minute read

I’ve been getting more and more interested in web graphics, particularly d3. All of this of course depends on javascript, a language I don’t know very well. As a way to start learning it, I thought I’d give Shiny a go, as a bridge between R and javascript (I’ve since started a javascript course proper). I’ve been surprised by how simple and powerful Shiny is, although the problems I ran into I wasn’t able to solve.

## How to make a GitHub pages blog with RStudio and Hugo

Or, how I produce this blog

15 minute read

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).

## Ranking Brad Pitt’s Movies in R

7 minute read

So I saw this blog post, in which Pretty Famous ranked every one of Brad Pitt’s movies (I have no idea how I came across it, I’m not particularly a movie buff or a fan of Señor Pitt, but anyway). Then I wondered how easy/hard it would be to do something like that in R. Pretty Famous used a few sources, but here I’m going to stick to Rotten Tomatoes, since it’s a pretty well-known movie ratings site, maybe the most well-known.

• Category
• R

## Tips and Tricks for R Markdown html

5 minute read

Here are a couple of little tips and tricks that I’ve picked up for use with RMarkdown html documents (including presentations and notebooks). This post is aimed at the R user who doesn’t know much, if anything, about html and css. Background images Sometimes it’s useful (or just nice) to have a background image of some sort in a presentation or notebook. This could be the logo of your university or company, for example.

## Make a colour table in R with ggplot2

3 minute read

I loved this R script from hdugan when I first saw it a while ago. The script makes a 2-page pdf of all the colors available in R, using R. Nice. The other day, I thought about making a tidyverse version of it, using dplyr to get the data ready and ggplot2 to visualize it. I won’t for a second pretend that this code is as short and tidy as the original, and in fact it may be a good example of when base R can be really useful, but anyway here it is.

## Suicides in Ireland

5 minute read

The Irish radio station newstalk published this video the other day, in which director and actor Terry McMahon spoke out against the austerity programme running in Ireland since the aftermath of the financial crisis in 2008. Leaving aside his conflation of any type of business activity with immorality, McMahon claimed that “austerity is murder” and detailed some alarming facts about suicide numbers in Ireland, clearly linking the two (i.e., austerity = more suicide).

• Category
• R

## Theme-Specific Voting in the European Parliament

7 minute read

Since it’s European Statistics Day, I thought I would make a quick post showing how to utilise some of the data that we have on the European Union in R. In particular, I will use European Parliament voting data from Simon Hix’s website. The data is freely available, so by copying and pasting the code below, you will be able to recreate the analysis I’ve done here. We’re going to be using Stan to make theme-specific ideal points for members of the European Parliament.

## Map-making with R and electionsBR

Create summaries and analyses using the R package electionsBR

8 minute read

For those interested in Brazilian politics, there’s a great new package called electionsBR (those who understand Portuguese can find a post on it here). This package takes data from the Tribunal Superior Eleitoral and makes it available in a tidy format for users of R. Given my recent obsession with map-making, I think it’s only natural I’d want to make maps of Brazil with this package.1 So, what can we do with it?

## Re-creating Plots from The Economist in R and ggplot2

4 minute read

5/2/2017 Update: it seems something is broken in the scripts to run this analysis. I’ll fix it asap.* The Economist is well known for its graphs and images, and I personally like them a lot. I was doing some work on Brexit when I spied the image above, and thought how much I would like to make something similar. Since my go-to environment is R, and its go-to plotting package ggplot2, I thought I’d try to recreate the image using these tools.

• Category
• R

## Geo-reference an image in R

2 minute read

R is actually great for working with spatial data (for example, see here and here for fantastic graphs and maps made with R), however, you often need data that is actually spatial to get started! What do you do if you have an image, a map, let’s say, that is not geo-referenced in any way? The regular answer to this problem is to use software such as QGIS to manually enter GPS coordinates, with the help of Google Maps or something similar.

• Category
• R