Skip to content

Instantly share code, notes, and snippets.

@mschnetzer
Last active August 14, 2018 16:41
Show Gist options
  • Save mschnetzer/5e7ea3df14da1cd7fe1048a9e92d6def to your computer and use it in GitHub Desktop.
Save mschnetzer/5e7ea3df14da1cd7fe1048a9e92d6def to your computer and use it in GitHub Desktop.
Schwierigkeiten Bildungsausgaben zu finanzieren (https://twitter.com/matschnetzer/status/976768713813889024)
library(eurostat)
library(tidyverse)
library(ggmap)
data <- get_eurostat("ilc_ats07",filters=list(deg_urb="TOTAL",hhtyp="TOTAL",incgrp="TOTAL",lastTimePeriod=1),type="code",time_format = "num") %>%
select(geo,lev_diff,values) %>% spread(lev_diff,values) %>% mutate(ease=EASY+FEASY+VEASY,difficult=GRT+MOD+SOME)
map <- get_eurostat_geospatial(output_class = "df", resolution = 10,update_cache = TRUE) %>% filter(STAT_LEVL_==0)
mapdat <- data %>% filter(!geo %in% c("EU28","EU27","EA19","EA18")) %>%
mutate(cat = cut(difficult,breaks = seq(0, 100, by = 20))) %>% select(geo,cat) %>%
mutate(cat=recode(cat,"(0,20]"="0-20%","(20,40]"=">20-40%","(40,60]"=">40-60%","(60,80]"=">60-80%","(80,100]"=">80-100%"))
eumap <- left_join(map,mapdat,by = c("NUTS_ID" = "geo"))
google.map <- get_map(location = 'Europe', zoom=3, maptype="satellite",crop = FALSE)
pdf(file="educ.pdf")
ggmap(google.map) + geom_polygon(aes(fill=cat, x=long,y=lat,group=group),
data = eumap, alpha = 0.5, color = "black", size=0.1) +
scale_fill_brewer(palette = 'YlOrRd') +
theme(axis.line=element_blank(),axis.text.x=element_blank(),
axis.text.y=element_blank(),axis.ticks=element_blank(),
axis.title.x=element_blank(),axis.title.y=element_blank(),
legend.title=element_blank(),legend.position="right")
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment