Early I posted a question about plotting county names on a map using ggplot and maps found HERE. My first approach was to take the means of all the lat and long coordinates
This was a very helpful discussion. For the benefit of those who grew up with dplyr, here is a minor tweak, using pipes in place of aggregate:
library(maps); library(dplyr); library(ggplot2)
ny <- map_data('county', 'new york')
cnames1 <- aggregate(cbind(long, lat) ~ subregion, data=ny,
FUN=function(x)mean(range(x)))
cnames2 <- ny %>% group_by(subregion) %>%
summarize_at(vars(long, lat), ~ mean(range(.)))
all.equal(cnames1, as.data.frame(cnames2))