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 / marriage.r
Created August 30, 2018 17:49
Mean age at first marriage, 1990-2014
library(tidyverse)
library(msthemes)
library(eurostat)
# Download data from UNECE: http://bit.ly/2wtn9Sp
data <- read.csv("marriage.csv",skip=1,na.strings=c("","..","NA"),dec=".")
data <- data %>% gather(year,value, -Sex, -Country)
data$year <- as.numeric(substring(data$year, 2))
# Change in EU countries where data is available
@mschnetzer
mschnetzer / wtg_gdppc.r
Last active September 4, 2018 13:05
World Tile Grid of Quintiles of GDP per capita, 1995-2015 (https://twitter.com/matschnetzer/status/1036879668606107648)
library(worldtilegrid)
library(plyr)
library(tidyverse)
library(countrycode)
library(viridis)
library(msthemes)
# Get GDP per capita data from UNdata http://bit.ly/2N4hUlV
data <- read.csv("undata.csv",dec=".") %>% rename(Country=Country.or.Area) %>% select(-Value.Footnotes)
@mschnetzer
mschnetzer / sciencepop.R
Created September 20, 2018 10:37
Scientists and engineers per 1,000 pop
library(tidyverse)
library(eurostat)
sci <- get_eurostat("hrst_st_nocc",filters=list(geo=eu_countries$code,unit="THS",isco08="TOTAL",category="SE",age="Y25-64",lastTimePeriod=1),type="code",time_format = "num") %>%
select(geo,values) %>% rename(sci=values)
pop <- get_eurostat("demo_gind",filters=list(geo=eu_countries$code,indic_de="JAN",lastTimePeriod=1),type="code",time_format = "num") %>%
select(geo,values) %>% rename(pop=values)
# Scientists are measures in Thousands
data <- left_join(sci,pop,by="geo") %>% mutate(scipop = round(sci*1000/pop*1000,0)) %>%
@mschnetzer
mschnetzer / estateprices.r
Last active October 14, 2018 19:15
Baugrundstückspreise nach Bezirken, 2017
# Download XLS, merge sheets and export as csv: http://www.statistik.at/web_de/statistiken/wirtschaft/preise/immobilien_durchschnittspreise/index.html
immodat <- read_csv2("baugrundstueckspreise_2017.csv",skip = 3) %>%
select(iso=B.Nr., preis=starts_with("Euro")) %>% add_row(iso=900,preis=1000) %>%
filter(!is.na(iso), !is.na(preis)) %>% mutate(preis=round(preis,-1)) %>%
mutate(preis=cut(preis,breaks=c(0,50,100,200,500,3000),
labels=c("<50€","50-100€","100-200€","200-500€",">500€")))
source("plotmap.R")
plotbezirke(dataset=immodat,fillvar="preis",wienbezirke=F,colpal=msc_palette[5:1],
@mschnetzer
mschnetzer / wohnkosten.r
Last active November 2, 2018 10:58
Anteil der Ausgaben für Miete am verfügbaren Haushaltseinkommen, 2017 (https://twitter.com/matschnetzer/status/1058312258978308097)
library(tidyverse)
library(msmaps)
library(eurostat)
data <- get_eurostat("ilc_mded02",filters=list(hhtyp="TOTAL",incgrp="TOTAL",time=c("2016","2017")),type="code",time_format="num") %>%
mutate(geo=recode(geo,"UK"="GB","EL"="GR")) %>% select(geo,time,values) %>%
group_by(geo) %>% fill(values) %>% filter(time==2017)
mapdata <- data %>%
mutate(cat = cut(values, breaks = c(0,15,20,25,30,35))) %>% select(geo,cat) %>%
library(tidyverse)
library(rdbnomics)
library(scales)
library(ggrepel)
library(msthemes)
unemp <- rdb(ids='OECD/MEI/AUT.LMUNRRTT.STSA.Q')
unemp$draw <- 1
unemp <- unemp %>% mutate(label = case_when(
value == max(value) ~ 1,
@mschnetzer
mschnetzer / passengergrowth.r
Last active December 7, 2018 08:30
Wachstum beförderter Fluggäste, 2007-2017 (https://twitter.com/matschnetzer/status/1070958511872466944)
library(tidyverse)
library(eurostat)
library(grid)
library(png)
library(msthemes)
# Load data
data <- get_eurostat("avia_paoc", filters = list(schedule="TOT",time = c("2007","2017"),tra_cov="TOTAL",tra_meas="PAS_CRD",unit="PAS"), time_format = "num")
# Calculate growth 2007-2017
library(tidyverse)
library(msmaps)
library(sf)
# Load data
pop <- read_csv2("population.csv") %>% filter(iso<901) %>% select(iso,pop)
quarter <- pop %>% summarise(sum(pop)/4) %>% as.numeric()
quarter <- quarter*c(0:4)
# Load Geodata
library(tidyverse)
library(eurostat)
library(countrycode)
library(msthemes)
library(lubridate)
library(png)
library(jpeg)
library(grid)
# Load tax rate data (https://ec.europa.eu/taxation_customs/sites/taxation/files/taxation_trends_report_2018_statutory_rates.xlsx)