I want facet_wrap to plot a map using a data variable in ggplot2 - for example. "pets" in the example below. Does this require complete duplication of fortified map data for each category of variables? It would hit me somehow stupid. Is there an alternative method?
require(ggplot2) (nz_dat = data.frame(island = rep(c('North.Island ','South.Island '), 3), pets = c('cats','cats','dogs','dogs','birds','birds'), n = c(13, 26, 48, 74, 24, 17))) island pets n 1 North.Island cats 13 2 South.Island cats 26 3 North.Island dogs 48 4 South.Island dogs 74 5 North.Island birds 24 6 South.Island birds 17 nz = map_data("nz") nz = subset(nz, nz$region %in% c('North.Island ','South.Island '))

source share