Publications by is.R()
Make your own electoral map
You’ve already seen everyone else’s electoral map (see this amazing array of maps from 2008), how would you like to make your own? Today’s Gist allows you to do just that — input (manually!) state-by-state results, and output a beautiful choropleth map of presidential election results! This code, of course, can be used for any number of s...
837 sym 2 img
Five Thirty-Hate?
The last few days have been trying, mostly because folks keep asking me the same questions: have you voted? Who do you think will win the election? Do you think Nate Silver (http://fivethirtyeight.blogs.nytimes.com/) is right? How confident are you in the forecasts at _________ (fill in your favorite election forecast site)? For example: http:/...
17761 sym 16 img
Interactive color picker, using locator()
I mostly wrote this just to see how locator() works, and ended up making an HCL color picker, so you can make your own visually offensive rainbow color palettes! Or, you can make your own nice color palettes. It is up to you. Essentially, this script generates a fair number of color points in HCL space, allows you to click on them in any sequenc...
1198 sym 4 img
Can’t a plot catch a break(s)?
This post continues with the theme of how to modify plots from within ggplot; today we will specifically looking at custom axis breaks. Plots later in the week will examine the commands to change text in the plot area. The various other shortcomings of this plot will be discussed in future posts. To create custom breaks on the Y-axis: https://gis...
758 sym 2 img
Textual Healing
While I know there are several awesome guides for how to make fine-tuning adjustments to plot labels/axes/ticks/text in ggplot, this is still the most common question I get from people new to ggplot: how do I change the size/font/color/position of (some text element)? Here are some examples. First, let’s load the made-up data from yesterday....
3484 sym 14 img
Textual Healing Part II
Yesterday’s post showed a number of quick coding options for changing text in a basic ggplot. Here’s another two tricks for fine-tuning faceted plots. Again, let’s load our made up data about tooth growth (a real dataset in R, ToothGrowth, has the real data if you’re interested). As usual, we begin with creating our dataset: https://gist....
2812 sym 10 img
Hjust and Vjust
So, when you’re setting the position of text in ggplot, you may have to use the hjust and vjust commands. Depending on your demands, and if you don’t understand what they’re doing, they might seem hard to use. I found one script that produces the graph below, as well as an excellent discussion here: http://goo.gl/TaUsG I have modified the c...
984 sym 2 img
Gathering RealClearPolitics Polling Trends with XML
Now that the election is over, you may want to use polling data in a model of the campaign. Simon Jackman has thoughtfully made his daily state-by-state predictions available for download, but a commonly-used dataset is the RealClearPolitics polling average. As you can see when you go to RCP, they have a nice HTML5 graph (screenshot above), over ...
1850 sym 4 img
Representing density in two dimensions
I’ll be subbing today for Chris, as we continue to explore some ggplot2 basics. Today, imagine that you have data distributed in two dimensions, and that you would like to convey differences in point density over space. As with many things, this is fairly easy to do with ggplot2, but it’s not quite as straightforward as it relies on the use o...
946 sym 2 img
Happy Thanksgiving from is.R()!
Today’s post is mostly to wish everyone a Happy Thanksgiving. We will be taking the rest of the week off, and will return on Monday. Below is some code to reproduce the adorable Turkey above; enjoy! https://gist.github.com/4122464 Related To leave a comment for the author, please follow the link and comment on their blog: is.R(). R-blogger...
620 sym 2 img