Skip to content

Instantly share code, notes, and snippets.

library('dplyr')
library('httr')
library('jsonlite')
options(stringAsFactors = FALSE)
url <- "http://www.gpirrotta.tk/arpa/api/misurazioni?id_stazione=1"
res <- GET(url)
@patperu
patperu / incidenti.svg
Last active June 26, 2016 08:30
Incidenti stradale - Palermo 2015
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@patperu
patperu / OpenCoesione.R
Last active August 7, 2016 15:35
OpenCoesione Rest API
library('httr')
library('jsonlite')
library('dplyr')
library('ggplot2')
library('scales')
options(stringsAsFactors = FALSE)
cp <- function(x) Filter(Negate(is.null), x)
dataDir <- file.path(projectDir, "dati")
files <- list.files(dataDir, recursive = TRUE, full.names = TRUE)
get_col_names <- function(files, ftype) {
ix <- which(tools::file_ext(files) == ftype)
col_names <- lapply(ix, function(x) {
readLines(files[x])[1]
})
@patperu
patperu / refpal.md
Last active April 19, 2016 13:57
refpal via curl at opencpu
# https://public.opencpu.org/ocpu/webhook

# https://github.com/patperu/refpal
curl -k https://patperu.ocpu.io/refpal/R/get_data/print

# function (url)
# {
  # x <- read_xml(url) %>% xml_nodes("SV") %>% html_attrs()
 # x &lt;- data.frame(do.call("rbind", x), stringsAsFactors = FALSE)
@patperu
patperu / anbsc_confiscati_per_comune_2015_12_31.R
Last active March 27, 2016 06:58
anbsc_confiscati_per_comune_2015_12_31
# see: http://www.confiscatibene.it/it
# Colonna 1. IdRegioneISTAT - Identificativo univoco della regione in cui è localizzato il bene confiscato, secondo la classificazione ISTAT (numero intero).
# Colonna 2. Regione - Nome della regione in cui è localizzato il bene confiscato (stringa di testo).
# Colonna 3. IdProvinciaISTAT - Identificativo univoco della provincia in cui è localizzato il bene confiscato, secondo la classificazione ISTAT (numero intero).
# Colonna 4. Provincia - Nome della provincia in cui è localizzato il bene confiscato (stringa di testo).
# Colonna 5. IdComuneISTAT - Identificativo univoco del comune in cui è localizzato il bene confiscato, secondo la classificazione ISTAT (numero intero).
# Colonna 6. Comune - Nome del comune in cui è localizzato il bene confiscato (stringa di testo).
# Colonne 7-20. Settori delle aziende - (numero intero).
# Colonna 21. Totale aziende - Totale delle aziende confiscate nella provincia corrispondente (numero intero).
@patperu
patperu / ReadWriteAccess.R
Last active March 24, 2016 13:39
Read/Write Access .accdb
# Works only with 32bit
library('RODBC')
options(stringsAsFactors = FALSE)
WriteAccess <- function(xdf, xtable) {
channel <- odbcConnectAccess2007("E:/mytest.accdb")
sqlSave(channel, tablename = xtable, xdf, safer = FALSE)
@patperu
patperu / bev_pgr.R
Created February 29, 2016 18:50
Bevölkerungsprognose Berlin, Ebene PGR
---
title: "Bevölkerungsprognose Berlin, Ebene PGR"
author: "Patrick Hausmann"
date: "29 Februar 2016"
# always_allow_html: yes
# output: rmarkdown::github_document
output: html_document
---
```{r setup, include=TRUE}
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 6.
"Inizio","Ente","Oggetto","Fine","link"
"23/02/2016","SERVIZI ISTITUZIONALI","CONVOCAZIONI VII^ CC.P "" AMBIENTE - VERDE PUBBLICO - SERVIZI PUBBLICI "" PER IL GIORNO 26/2/2016 ALLE ORE 11,30 E PER IL GIORNO 29/02/2016 ALLE ORE 15,30.","29/02/2016","AlboPretorio1$dgRisultati$ctl03"
"23/02/2016","PM","DETERMINA N.93 DEL 27/01/2016 - SETTORE VIGILANZA E PROTEZIONE CIVILE: ANCITEL PER CONSULTAZIONE BANCA DATI ANNO 2016 SIC. IMPEGNO DI SPESA .","09/03/2016","AlboPretorio1$dgRisultati$ctl04"
"23/02/2016","CULTURA - TEATRO","DETERMINA N.128 DEL 01/02/2016 - SETTORE BENI E SERVIZI CULTURALI-TEATRO: QUOTA ASSOCIATIVA DOVUTA AL TEATRO PUBBLICO PUGLIESE PER L'ANNO 2016.","09/03/2016","AlboPretorio1$dgRisultati$ctl05"
"23/02/2016","CULTURA - TEATRO","DETERMINA N.189 DEL 11/02/2016 - SETTORE BENI E SERVIZI CULTURALI-TEATRO: APPALTO PER LA GESTIONE DEI SERVIZI AUSILIARI RELATIVI AL TEATRO COMUNALE G. CURCI DI BARLETTA - NOMINA COMMISSIONE","09/03/2016","AlboPretorio1$dgRisultati$ctl06"
"23/02/2016","AMBIENTE","DETE
@patperu
patperu / ap_parse.R
Last active February 18, 2016 17:08
Parse several different Albo Pretorio providers
# studiok
res <- ap_parse_page(url = "http://albo.studiok.it/lu/albo", site = "studiok")
str(res)
## Classes 'albopop_srs' and 'data.frame': 39 obs. of 7 variables:
## $ APNumero : chr "59 / 2016" "58 / 2016" "57 / 2016" "56 / 2016" ...
## $ Descrizione: chr "" "" "" "" ...
## $ Tipo : chr "VARIE COMUNE DI LU" "DELIBERA DI GIUNTA" "DELIBERA DI GIUNTA" "DELIBERA DI GIUNTA" ...
## $ Oggetto : chr "[59 / 2016] CONTRIBUTI REGIONALI PER RACCOLTA, TRASPORTO E SMALTIMENTO DI PICCOLI QUANTITATIVI DI AMIANTO (ETERNIT)" "[58 / 2016] DELIBERA GIUNTA COMUNALE N. 109 DEL 12/11/2015" "[57 / 2016] DELIBERA GIUNTA COMUNALE N. 56 DEL 07/07/2015" "[56 / 2016] DELIBERA GIUNTA COMUNALE N. 120 DEL 18/12/2015" ...
## $ Inizio : chr "18/02/2016" "18/02/2016" "18/02/2016" "18/02/2016" ...
## $ Fino : chr "24/02/2016" "04/03/2016" "04/03/2016" "04/03/2016" ...