Skip to content

Instantly share code, notes, and snippets.

@mschnetzer
Last active August 14, 2018 16:40
Show Gist options
  • Save mschnetzer/8399d5760dab734ca429c421b6d7d4b1 to your computer and use it in GitHub Desktop.
Save mschnetzer/8399d5760dab734ca429c421b6d7d4b1 to your computer and use it in GitHub Desktop.
Bereitschaft junger Arbeitsloser für einen Job umzuziehen (https://twitter.com/matschnetzer/status/978691554754916352)
library(eurostat)
library(tidyverse)
library(forcats)
data <- get_eurostat("lfso_16move4j",filters=list(age="Y20-34",wstatus="UNE",sex="T",isced11="TOTAL",workstud="TOTAL"),type="code") %>%
select(geo,mobility,values) %>% spread(mobility,values)
cube <- data %>% group_by(geo) %>% mutate(pop=ifelse(is.na(NRP),TOTAL,TOTAL-NRP),
known=sum(MOV_EU_FOR,MOV_EXT_EU,MOV_NAT,NMOV,na.rm=TRUE),
unknown=pop-known,
nonmov=NMOV/pop*100,
movex=MOV_EXT_EU/pop*100,
moveu=MOV_EU_FOR/pop*100,
movnat=MOV_NAT/pop*100,
rest=unknown/pop*100)
df <- cube %>% filter(!geo %in% c("LU","IS","MT","CH")) %>% select(geo,movex,moveu,movnat,rest) %>%
gather(type,value,movex:rest) %>% replace_na(list(value=0))
ggplot(df, aes(x = reorder(geo,value), y = value, fill = fct_rev(type))) +
geom_bar(position = "stack", stat = "identity") +
coord_flip() + xlab("") + ylab("Arbeitslose 20 bis 34-Jährige, in %") +
scale_fill_discrete(name="Bereit für Job umzuziehen",
breaks=c("moveu", "movex", "movnat","rest"),
labels=c("in anderes EU-Land", "außerhalb der EU", "innerhalb des Landes", "nicht zuordenbar")) +
ggsave("jobmoving.pdf", scale=1.5, width=6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment