I have following data which I want to plot on States map of the USA:
x = data.frame(state.x77[,"Income"])
How can I plot these as color fill in states on a map?
I can plot the map:
map("state", boundary=TRUE, col=colorRampPalette(c("blue","green","yellow","red"))(50), fill=T)
I can match the states:
match(map("state",plot=F)$names, tolower(rownames(x)))
I tried to modify example from ?map_data :
if (require("maps")) {
states <- map_data("state")
arrests <- USArrests
names(arrests) <- tolower(names(arrests))
arrests$region <- tolower(rownames(USArrests))
choro <- merge(states, arrests, sort = FALSE, by = "region")
choro <- choro[order(choro$order), ]
qplot(long, lat, data = choro, group = group, fill = assault,
geom = "polygon")
qplot(long, lat, data = choro, group = group, fill = assault / murder,
geom = "polygon")
}
But I am not able to adjust it. Thanks for your help.