Untitled

 avatar
unknown
r
3 years ago
695 B
5
Indexable
# Get europe countries coordinates to place their name correctly in the map
countries.maps <- map_data("world", region = european_union)

# Every country data has more than one lat and long, 
# therefore we group and get the mean
eu_coords <- countries.maps %>%
  group_by(region) %>%
  summarize(
    long = mean(long, na.rm = T), 
    lat = mean(lat, na.rm = T), 
    group = group
  )

# Remove duplicated rows after the filtering
eu_coords <- eu_coords[!duplicated(eu_coords), ]

european_union_map <- 
  world_map %>% 
  filter(name %in% european_union)
  
  .
  .
  .
  
  
... + geom_text(data = eu_coords, aes(long, lat, label = region, group = group), size = 2)
Editor is loading...