我仍在学习R,我想用每个州发生的犯罪数量的标签映射美国。我要创建下面的图像。
我使用了下面的代码,这些代码可在线获得,但无法标记为“犯罪无”。
library(ggplot2)
library(fiftystater)
data("fifty_states")
crimes <- data.frame(state = tolower(rownames(USArrests)), USArrests)
p <- ggplot(crimes, aes(map_id = state)) +
# map points to the fifty_states shape data
geom_map(aes(fill = Assault), map = fifty_states) +
expand_limits(x = fifty_states$long, y = fifty_states$lat) +
coord_map() +
scale_x_continuous(breaks = NULL) + scale_y_continuous(breaks = NULL) +
labs(x = "", y = "") + theme(legend.position = "bottom",
panel.background = element_blank())
Run Code Online (Sandbox Code Playgroud)
有人可以帮我吗?