Skip to content

Instantly share code, notes, and snippets.

@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() |>
library(tidyverse)
library(eurostat)
library(countrycode)
library(gt)
library(gtExtras)
data <- get_eurostat("prc_hicp_manr", filters = list(coicop = "CP00"))
ea.avg <- data |> filter(geo == "EA") |> slice_max(time, n=1) |> pull(values)
@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)) +
@mschnetzer
mschnetzer / arctic_ice.R
Last active July 25, 2023 21:08
Ausdehnung des arktischen Eises im Jahresverlauf
library(tidyverse)
library(gghighlight)
library(ggtext)
# Data download: https://ads.nipr.ac.jp/vishop/#/extent
raw <- read.csv("VISHOP_EXTENT_GRAPH.csv")
dat <- raw |>
select(month, day = date, X1989:X2023) |>
pivot_longer(cols = X1989:X2023, names_to = "year", values_to = "ice",
librarian::shelf(tidyverse, pdftools, geojsonsf, sf, ggtext, patchwork)
# PDF herunterladen und Seite 3 extrahieren
rawpdf <- pdf_text("https://www.parlament.gv.at/dokument/XXVII/AB/14482/imfname_1572157.pdf")
rawpdf <- rawpdf[3]
# Rohdaten in Zeilen umwandeln und Datenbereich auswählen
lines <- strsplit(rawpdf, '\n') |> unlist() |> str_trim(side = "left")
short <- lines[c(11:24,30:36,42:63)]
library(tidyverse)
library(rvest)
library(cropcircles)
library(magick)
library(gt)
library(gtExtras)
data <- read_html("https://sport.orf.at/stories/3111293/") |>
html_elements("section") |>
html_table() |>