Black theme for ggplot2

[EDIT 06/05/16: See updated version of this code here for ggplot2 version 2.X.X:]

I’ve long extolled the virtues of using ggplot2 as a graphing tool for R for its versatility and huge feature set. One of my favorite aspects of ggplot2 is the ability to tweak every aspect of the plot using intuitive commands. With the recent release of version 0.9.2 though, creator Hadley Wickham overhauled the theme options, which broke my preferred black theme, theme_black(), found here. I’ve updated theme_black() to work with the current version of ggplot Enjoy!

ggplot2black Continue reading

Mapping in R, Part II

The other day, I posted an introductory demo to mapping in R using some of the built-in maps. But of course there are only a few regions represented in the “maps” package: the US states, the US as a whole, Italy, France, and the world. Even then, there are some limitations to these: for instance, the USSR is still alive and kicking in the world of “maps.” If you are living in the 21st century–or working somewhere other than these locations–you may want to supply your own, more updated maps. The most popular filetype is, of course, the GIS shapefile. But to access, visualize, manipulate, and plot on shapefiles, it was formerly necessary to use ArcGIS, which is proprietary and thus costly. I’ll show you how to do it all in R!

Continue reading

Mapping in R, Part I

I’m consistently amazed at the capabilities of R: if it can be done, it can be done in R. And so is the case with mapping. Recently, I had the need to do some complicated geospatial analysis, and I wanted to do it in R for the obvious reasons: it’s free, it’s open-source, and there is a great support community. As it turns out, R has much of the functionality of ArcGIS, albeit with a lot less flash and a lot more hair-pulling. But once you’ve done the legwork to get the data in and formatted, and the functions set, it’s a snap to run through all sorts of data.

Continue reading