Skip to content

Instantly share code, notes, and snippets.

View giocomai's full-sized avatar

Giorgio Comai giocomai

View GitHub Profile
@giocomai
giocomai / Words disappearing from SOTEU animated.R
Last active September 12, 2018 15:18
Words disappearing from SOTEU animated
# load libraries
library("gganimate")
library("tidyverse")
# introduce data
structure(list(id = c("Barroso\n2010", "Barroso\n2010", "Barroso\n2010",
"Barroso\n2011", "Barroso\n2011", "Barroso\n2011", "Barroso\n2012",
"Barroso\n2012", "Barroso\n2012", "Barroso\n2013", "Barroso\n2013",
@giocomai
giocomai / fertility_age_eurostat.Rmd
Created August 7, 2018 20:01
Replicate NY times birth-age gap with Eurostat data
---
title: "Birth age gap"
author: "Giorgio Comai"
date: "7 August 2018"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library("geofacet")
library("ggplot2")
library("tidyverse")
library("scales")
library("readxl")
# dati ripuliti: https://data.world/sapomnia/elezioni-2018/workspace/file?filename=Risultati%20elezioni%20camera%202018%20livello%20comunale.xlsx
# basato su: https://github.com/ondata/elezionipolitiche2018
comune <- readxl::read_excel("Risultati elezioni camera 2018 livello comunale.xlsx")
@giocomai
giocomai / Exploring Putin’s annual news conference.Rmd
Created December 15, 2017 13:38
Exploring Putin’s annual news conference 2017
---
title: "Exploring Putin's annual news conference"
author: "Giorgio Comai"
date: '2017-12-15'
---
```{r setup, include=FALSE, echo=TRUE, message=FALSE}
knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE)
@giocomai
giocomai / MEPsOnTwitter_rtweet.R
Last active October 19, 2017 14:36
Extract the full twitter history of all current members of the European Parliament with R (rtweet) #rstats
if (!require("pacman")) install.packages("pacman") # for taking care of package installation/loading
pacman::p_load("tidyverse")
pacman::p_load("ROAuth")
pacman::p_load("rtweet")
# this assumes authentication has been taken care of as explained here: http://rtweet.info/articles/auth.html
# it should still work, but without access tokens the limits for API requests are much slower (it would take *a lot* longer to get all tweets)
# it is expected that this script will need to be run more than once
# interim files are automatically stored and recovered if the script is re-run
@giocomai
giocomai / 2017-09-19 - EuropeanUnion - EuropeanCommission.R
Last active September 27, 2017 19:03
Extract all press releases, speeches and statements issued by the European Commission with R and castarter
## Install castarter (devtools required for installing from github)
# install.packages("devtools")
devtools::install_github(repo = "giocomai/castarter", ref = "development")
setwd("~/R")
## Load castarter
library("castarter")
## Set project and website name
SetCastarter(project = "EuropeanUnion", website = "EuropeanCommission")
@giocomai
giocomai / 2017-09-19 - EuropeanUnion - EuropeanCommission.R
Created September 27, 2017 18:54
Extract all press releases, speeches and statements issued by the European Commission with R and castarter
## Install castarter (devtools required for installing from github)
# install.packages("devtools")
devtools::install_github(repo = "giocomai/castarter", ref = "development")
setwd("~/R")
## Load castarter
library("castarter")
## Set project and website name
SetCastarter(project = "EuropeanUnion", website = "EuropeanCommission")
@giocomai
giocomai / install Ghostwriter on Fedora.sh
Last active December 11, 2022 12:03
Install Ghostwriter markdown editor on Fedora 30
sudo dnf install qt-devel hunspell-devel qt5-qtwebkit-devel qt5-qtsvg-devel qt5-qtsvg-devel qt5-qtmultimedia-devel qt5-qtbase qt5-linguist qt5-qtwebengine-devel
wget https://github.com/wereturtle/ghostwriter/archive/v1.8.0.tar.gz
tar -xvzf v1.8.0.tar.gz
cd ghostwriter-1.8.0/
/usr/lib64/qt5/bin/qmake-qt5
@giocomai
giocomai / SOTEU2017_post.Rmd
Last active September 13, 2017 09:19
Exploring SOTEU speeches
---
title: 'Exploring #SOTEU speeches'
author: "Giorgio Comai (OBC Transeuropa/#edjnet)"
date: "13 September 2017"
output:
html_document:
code_folding: hide
theme: readable
---
@giocomai
giocomai / 2017-06-19-wikipediaTurk.R
Created June 20, 2017 07:26
Create graph with pageviews to Turkish language Wikipedia projects (April-June 2017)
library("rvest")
library("tidyverse")
library("lubridate")
library("scales")
Sys.setlocale(category = "LC_TIME", locale = "en_IE")
dumpListApril <- read_html("https://dumps.wikimedia.org/other/pageviews/2017/2017-04/")
linksApril <- data_frame(filename = html_attr(html_nodes(dumpListApril, "a"), "href")) %>% # extracting links
filter(grepl(x = filename, "projectviews")) %>% # keeping only aggregated data by project