Using Hadley’s great ggplot2 and his book (pp. 78-79), I am able to produce single choropleth map plots with ease, using code like this:
states.df <- map_data("state")
states.df = subset(states.df,group!=8) # get rid of DC
states.df$st <- state.abb[match(states.df$region,tolower(state.name))] # attach state abbreviations
states.df$value = value[states.df$st]
p = qplot(long, lat, data = states.df, group = group, fill = value, geom = "polygon", xlab="", ylab="", main=main) + opts(axis.text.y=theme_blank(), axis.text.x=theme_blank(), axis.ticks = theme_blank()) + scale_fill_continuous (name)
p2 = p + geom_path(data=states.df, color = "white", alpha = 0.4, fill = NA) + coord_map(project="polyconic")
Where “value” is the vector of state-level data I am plotting. But what if I want to plot multiple maps, grouped by some variable (or two)?
Here’s an example of a plot done by Andrew Gelman, later adapted in the New York Times, about health care opinion in the states:

I’d love to be able to emulate this example: show choropleth plots gridded according to two variables (or even one). So I pass not a vector of values, but rather a dataframe organized “long”, with multiple entries for each state.
I know ggplot2 can do this, but I’m not sure how. Thanks!
You can add two columns for the desired groupings and use facets: