Skip to content

Instantly share code, notes, and snippets.

View mschnetzer's full-sized avatar

Matthias Schnetzer mschnetzer

View GitHub Profile
@mschnetzer
mschnetzer / corruption.R
Created February 16, 2025 07:39
Korruptionsindex 2024
library(tidyverse)
library(readxl)
library(gt)
library(gtExtras)
library(gtUtils)
library(countrycode)
library(colorspace)
# Download https://images.transparencycdn.org/images/CPI2024-Results-and-trends.xlsx
data <- read_xlsx("CPI2024-Results-and-trends.xlsx",
library(tidyverse)
library(eurostat)
rawdat <- get_eurostat("tipsnf10", filters = list(geo = "AT"), time = "date", type = "label", lang = "de")
gdpdat <- get_eurostat("nama_10_gdp", filters = list(geo = "AT", unit = "CP_MEUR", na_item = "B1GQ"), time = "date", type = "label", lang = "de")
findat <- rawdat |>
mutate(values = ifelse(sector == "Volkswirtschaft", values*-1, values),
sector = case_match(sector,
library(tidyverse)
library(ggsankey)
library(ggtext)
library(colorspace)
# Daten von https://www.bmi.gv.at/412/Europawahlen/Europawahl_2024/files/endgueltiges_Ergebnis_Europawahl_26062024.xlsx
raw <- readxl::read_xlsx("endgueltiges_Ergebnis_Europawahl_26062024.xlsx")
# Daten auswählen, neue Variablen generieren, in Long-Format bringen
data <- raw |> filter(Gebietsname == "Österreich") |>
library(tidyverse)
library(eurostat)
library(ggflags)
library(countrycode)
library(geomtextpath)
library(ggtext)
data <- get_eurostat("icw_tax_03")
plotdat <- data |>
@mschnetzer
mschnetzer / banks.R
Created April 5, 2024 14:39
Quarterly profits in the banking sector
library(tidyverse)
library(oenb)
library(colorspace)
library(futurevisions)
# Load data on quarterly profits in the banking sector
data <- oenb_data(id = "3104", pos = "VDBKICBD66EL210") |>
select(period, value) |>
as_tibble()
@mschnetzer
mschnetzer / gfcf.R
Last active March 17, 2024 13:03
Bruttoanlageinvestitionen in % des BIP (https://x.com/matschnetzer/status/1768627118580089130?s=20)
library(tidyverse)
library(countrycode)
library(rdbnomics)
library(ggbump)
library(MetBrewer)
library(scales)
allcty <- codelist |> filter(!is.na(eu28)) |> pull(iso3c) |> tolower()
gfcf_private <- rdb(provider_code = "AMECO", dataset_code = "UIGP",
@mschnetzer
mschnetzer / pkw.R
Created March 7, 2024 12:25
PKW-Neuzulassungen 2010-2023 nach Antriebsart
library(tidyverse)
library(ggstream)
library(pdftools)
library(wesanderson)
library(ggpp)
raw <- pdf_text(pdf = "https://www.statistik.at/fileadmin/pages/77/Pressemappe_2023.pdf")
pkw <- unlist(strsplit(raw[15], split = "\n")) |>
str_trim(side = "left") |>
# GRAFIK: Anteil Kinder mit Mittagessen in der Betreuungseinrichtung
library(tidyverse)
library(readODS)
library(sf)
library(ggtext)
library(patchwork)
bez <- geojsonsf::geojson_sf("https://raw.githubusercontent.com/ginseng666/GeoJSON-TopoJSON-Austria/master/2021/simplified-99.9/bezirke_999_geo.json")
@mschnetzer
mschnetzer / timeuse.R
Created January 17, 2024 16:55
Geschlechtsspezifische Aufteilung von Sorgearbeit (https://x.com/matschnetzer/status/1747624651902099745?s=20)
library(tidyverse)
library(readODS)
# Daten unter https://www.statistik.at/fileadmin/pages/298/Durchschnittliche_Zeitverwendung_2021-22.ods
longdata <-
read_ods("Durchschnittliche_Zeitverwendung_2021-22.ods",
sheet = "Tabelle_17", range = "A5:J129", col_names = F,
col_types = "ctcttcttct") |>
janitor::clean_names() |>
@mschnetzer
mschnetzer / vinyl.R
Last active August 31, 2023 07:10
Sales revenue of vinyl in the US, 1973-2022 (https://twitter.com/matschnetzer/status/1697144639394902260?s=20)
library(tidyverse)
library(ggforce)
library(geomtextpath)
# Download data from here: https://www.riaa.com/u-s-sales-database/
vinyl <- read_csv2("vinyl.csv") |>
select(year = Year, value = `Value (Actual)`)
vinyl |>
ggplot(aes(x = year, y = 1)) +