Skip to content

Instantly share code, notes, and snippets.

View psobczyk's full-sized avatar

Piotr Sobczyk psobczyk

View GitHub Profile
@psobczyk
psobczyk / sejm.R
Created October 22, 2019 22:04
Analysis of polish general elections 2019
# Files with data come from https://wybory.gov.pl/sejmsenat2019/pl/dane_w_arkuszach
require(dplyr)
require(magrittr)
require(tidyr)
require(broom)
require(ggparliament)
# Sejm elections. Could void votes affect results?
@psobczyk
psobczyk / url-mapping-disqus.R
Created September 19, 2020 12:57
Creating an url mapping when migrating from Wordpress to Hugo
library(xml2)
library(rvest)
doc <- read_html(x = "path_to_xml_file")
threads <- xml_find_all(doc, ".//thread")
old_links <- gsub(".* (http.*)", "\\1", xml_text(xml_find_all(threads, xpath = ".//id")))
old_titles <- xml_text(xml_find_all(threads, xpath = ".//title"))