Reputation: 1225
I am trying to draw a white border around state boundaries. I can't figure out why the example below throws an error as it seems to be consistent with the documentation. What is the right way? Thanks.
#http://docs.ggplot2.org/0.9.2.1/geom_map.html
crimes <- data.frame(state = tolower(rownames(USArrests)), USArrests)
library(reshape2) # for melt
crimesm <- melt(crimes, id = 1)
if (require(maps)) {
states_map <- map_data("state")
gg<-ggplot(crimes, aes(map_id = state))
gg<-gg + geom_map(aes(fill = Murder), map = states_map) + expand_limits(x = states_map$long, y = states_map$lat)
gg<- gg + coord_map()
#works
print(gg)
#Now try to add a borders layer
#throws "Error in eval(expr, envir, enclos) : object 'state' not found"
print(gg+borders("state",colour="white"))
}
Upvotes: 0
Views: 2016