小编kav*_*esh的帖子

如何使用R将美国所有州与每个州发生的犯罪数量对应起来?

我仍在学习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)

有人可以帮我吗?

r ggplot2

4
推荐指数
1
解决办法
2385
查看次数

标签 统计

ggplot2 ×1

r ×1