Skip to content

Instantly share code, notes, and snippets.

@mschnetzer
mschnetzer / part-time-AT.R
Last active August 14, 2018 16:42
Gründe für Teilzeitarbeit nach Geschlecht in Österreich (https://twitter.com/matschnetzer/status/974591614244020226)
library(tidyverse)
library(waffle)
library(viridis)
data <- data_frame(
labs = c("Betreuung/Pflege","Keine Vollzeit gewünscht","Andere persönliche Gründe","Keine Vollzeit gefunden",
"Aus-/Fortbildung","Krankheit","Sonstige Gründe"),
male = c(4.6,18.8,14.4,17.3,29.9,5.9,9.2),
female = c(38.6,19.2,16.54,10.5,8.9,2.5,3.7)
)
@mschnetzer
mschnetzer / gender-pay-gap-AT
Last active August 14, 2018 16:42
Geschlechtsspezifische Lohnunterschiede nach Bezirken in Österreich, 2016 (https://twitter.com/matschnetzer/status/971761410974846976)
library(maptools)
library(ggplot2)
library(readr)
library(dplyr)
# Download SHP file from http://data.statistik.gv.at/web/meta.jsp?dataset=OGDEXT_POLBEZ_1
# load map
map=readShapeSpatial("shp2018/STATISTIK_AUSTRIA_POLBEZ_20180101",verbose=TRUE)
class(map)
names(map@data)
library(eurostat)
library(tidyverse)
library(RColorBrewer)
library(ggthemes)
# Vector with capital cities only
caps <- c(paste0(c("AT","BE","BG","CY","CZ","DE","DK","EE","EK","EL","ES","FI","FR","HR","HU","IE","IS",
"IT","LT","LU","LV","MT","NO","PL","PT","RO","SE","SI","SK","TR"), '001C1'),"NL002C1","FI001C2","UK001K2")
# Load data from Eurostat Perception Survey
@mschnetzer
mschnetzer / education.r
Last active August 14, 2018 16:41
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) %>%
@mschnetzer
mschnetzer / overtime.R
Last active August 14, 2018 16:40
Anteil unvergüteter Überstunden in Österreich, 2017 (https://twitter.com/matschnetzer/status/977193452650881024)
library(tidyverse)
library(ggthemes)
# load data
overtime <- read_csv2("overtime.csv") %>% mutate(highest=pmax(Männer,Frauen)) %>% arrange(highest) %>%
mutate(Wirtschaftszweig = factor(Wirtschaftszweig, levels = .$Wirtschaftszweig)) %>%
gather(Geschlecht,value,Männer:Frauen)
# labels
right_label <- overtime %>%
@mschnetzer
mschnetzer / jobmoving.r
Last active August 14, 2018 16:40
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,
@mschnetzer
mschnetzer / gini_DE_AT
Created April 3, 2018 08:10
Vergleich Einkommens-Gini Deutschland und Österreich
library(tidyverse)
library(eurostat)
library(ggthemes)
eurostat <- get_eurostat("ilc_di12",filters=list(geo=c("AT","DE")),type="code",time_format="num")
eurostat$time <- as.factor(eurostat$time)
eurostat %>% filter(time %in% 2005:2016) %>%
ggplot(aes(x=time,y=values,group=geo,colour=factor(geo,labels=c("Österreich","Deutschland")))) +
geom_line(size=1.2) + geom_point(size=1.2) + xlab(" ") +
ylab("Gini-Koeffizient") + labs(color = " ") + theme_fivethirtyeight() +
@mschnetzer
mschnetzer / healthafford.r
Last active August 14, 2018 16:39
Leistbarkeit von Gesundheitsleistungen in der EU (https://twitter.com/matschnetzer/status/982250661411565569)
library(eurostat)
library(tidyverse)
library(RColorBrewer)
library(ggthemes)
data <- get_eurostat("ilc_ats12",filters=list(hhtyp="TOTAL",incgrp="TOTAL",unit="PC_POP"),type="label",lang="de") %>%
select(geo,lev_diff,values) %>% spread(lev_diff,values) %>%
mutate(leicht=`Leicht `+`Relativ leicht `+`Sehr leicht`,schwierig=Groß+Mässig+Einige) %>%
filter(!geo %in% c("Europäische Union (derzeitige Zusammensetzung)", "Europäische Union (vor dem Beitritt Kroatiens)",
"Euroraum (19 Länder)", "Euroraum (18 Länder)")) %>%
library(eurostat)
library(tidyverse)
library(stringr)
library(lubridate)
library(ggridges)
library(viridis)
library(ggthemes)
# Only EU countries
cty = eu_countries$code
library(tidyverse)
library(eurostat)
library(ggmap)
library(msthemes)
# Get Eurostat data and calculate diff 2010-2017
data <- get_eurostat("prc_hpi_a",filters=list(typpurch="TOTAL",unit="INX_A_AVG",time=c(2010,2017)),type="code",time_format="num") %>%
select(geo,time,values) %>% group_by(geo) %>% mutate(inc=(values-lag(values))/lag(values)*100) %>% filter(!is.na(inc)) %>% select(geo,inc)
# Create categories for changes in house prices