library(eurostat)
library(dplyr)
library(ggplot2)
dat <- get_eurostat("ilc_peps01", time_format = "raw", stringsAsFactors = FALSE) %>%
dplyr::filter(time == 2014,
age == "TOTAL",
sex == "T",
unit == "PC")
## If you want only label the geo variable
# dat$geo_lab <- label_eurostat(dat$geo, countrycode = "cldr.short.ru", dic = "geo")
dat <- label_eurostat(dat, countrycode = "cldr.short.fi", dic = "geo", code = "geo")
# Download geospatial data from GISCO
geodata <- get_eurostat_geospatial(resolution = "60", nuts_level = "0", year = 2013)
geodata <- rename(geodata, geo_code = geo)
# merge with attribute data with geodata
map_data <- inner_join(geodata, dat)
labdat <- bind_cols(map_data %>% sf::st_set_geometry(NULL) %>% select(geo,values),
as_data_frame(sf::st_coordinates(sf::st_centroid(map_data))))
ggplot(data=map_data) +
geom_sf(aes(fill=values),color="dim grey", size=.1) +
labs(title="People at risk of poverty or social exclusion in 2014",
fill = "population share (%)",
caption="(C) EuroGeographics for the administrative boundaries
Map produced in R with a help from Eurostat-package <github.com/ropengov/eurostat/>") +
theme_light() +
geom_label(data = labdat, aes(x = X, y = Y, label = geo, fill = values), color = "white", alpha = .6, show.legend = FALSE) +
coord_sf(xlim=c(-12,44), ylim=c(35,70))
