Fine-looking R plots

While strolling through a friend’s copy of The Economist today, admiring a very coherent visual identity they chose, I remembered reading this blog post about R having such a theme a while back.

Lead by curiosity, I gave it a try.

Blue makes for a soothing colour to present such shocking data, don’t you think?

Quick instructions…

Install R

If you don’t have it already, you can install R easilty in Ubuntu:

sudo apt-get install r-base r-base-dev libcurl3-dev
sudo R

Also, I warmly recommend RStudio as an IDE for R.

Install ggplot2 and ggthemes

Once you started R as sudo, let’s install the packages:

install.packages("ggplot2")
install.packages("devtools")
library("devtools")
install_github("ggthemes", "jrnold")

Start playing

You can find some nice examples in the ggplot2 documentation. I tried this one:

library("ggplot2")
library("ggthemes")
p <- ggplot(mpg, aes(displ, hwy))
p + theme_economist() + geom_jitter(aes(colour = cyl)) + ggtitle("Kermit & the R-conomist")

An encountered problem

I couldn’t install devtools in Ubuntu, which is necessary to quickly get the github-hosted ggthemes package, because RCurl couldn’t be configured. To solve it, a small hint in this FAQ lead me to a solution in the end. You need to have this development version of the libcurl package:

sudo apt-get install libcurl3-dev

 

Published by

metakermit

Building apps, analysing data at Punk Rock Dev and sharing weird & cool photographs, drawings, music, films, games... More about me here. You can get new blog posts via RSS or follow @metakermit on Twitter where I also announce new stuff.

Leave a Reply

Your email address will not be published. Required fields are marked *