Import libraries
library(ggplot2)
library(dplyr)
library(maps)
require(viridis)
Retrieve Map Data
# Some EU Contries
some.eu.countries <- c(
"Portugal", "Spain", "France", "Switzerland", "Germany",
"Austria", "Belgium", "UK", "Netherlands",
"Denmark", "Poland", "Italy",
"Croatia", "Slovenia", "Hungary", "Slovakia",
"Czech republic"
)
# Retrieve the map data
some.eu.maps <- map_data("world", region = some.eu.countries)
# Compute the centroid as the mean longitude and lattitude
# Used as label coordinate for country's names
region.lab.data <- some.eu.maps %>%
group_by(region) %>%
summarise(long = mean(long), lat = mean(lat))
Develop a simple MAP
ggplot(some.eu.maps, aes(x = long, y = lat)) +
geom_polygon(aes( group = group, fill = region))+
geom_text(aes(label = region), data = region.lab.data, size = 3, hjust = 0.5)+
scale_fill_viridis_d()+
theme_void()+
theme(legend.position = "none")
