Site icon R-bloggers

Congressional ideology by state

[This article was first published on is.R(), and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

In a recent post, I illustrated how to add a background geom to your ggplot. While that code worked, and the plot looked fine, it was pointed out to me that I was missing an important aspect of plot layering with ggplot2. Namely, it is not, as I previously claimed, necessary to add extra NULL variables to the background data.frame.

Fortunately, I was put on the right path by the inimitable Hadley Wickham, who pointed out that There is, of course, a Function for That: mutate()

This Gist correctly builds a layered plot, shows how mutate() works, and plots DW-NOMINATE House ideology in two-dimensions, by state, with an illustration of what I consider a very useful visualization technique — adding a reference distribution to each plot facet.

https://gist.github.com/3927220
To leave a comment for the author, please follow the link and comment on their blog: is.R().

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.