ggplot centered names on a map

前端 未结 4 1752
伪装坚强ぢ
伪装坚强ぢ 2020-11-29 03:27

I\'m attempting to use ggplot2 and maps to plot the names of the counties in NY state. My approach was to find the means of latitude and longitude by county (I assume this

4条回答
  •  日久生厌
    2020-11-29 04:05

    It sorta seems like kmeans centers would be useful... Here is a poor start... its late!

    center.points <- ddply(ny, .(group), function(df) kmeans(df[,1:2], centers=1)$centers)    
    center.points$county <- ny$county[ny$group == center.points$group]
    p + geom_text(data=center.points, aes(x=V1, y=V2, label=county))
    

提交回复
热议问题