Skip to content

Instantly share code, notes, and snippets.

@patperu
patperu / eta_media.R
Created August 27, 2015 08:02
STATISTICA SUI DATI DI GENERE - distribuzioni per sesso, età e cittadinanza per le 8 circoscrizione
library('dplyr')
library('reshape2')
library('ggplot2')
library('Hmisc')
options(stringsAsFactors=FALSE)
getFiles <- function(m) {
@patperu
patperu / Emilia-Romagna.json
Created March 2, 2014 19:51
Emilia-Romagna.json // topojson
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@patperu
patperu / G62.R
Last active August 29, 2015 13:57
Plot "G62 -- Grado di diffusione di Internet nelle famiglie"
# see http://bit.ly/Nt5jpg
# http://www.datamediahub.it/2014/03/18/societa-dellinformazione-il-ritmo-di-crescita-delle-regioni-in-10-anni-mappa-interattiva/
library(ggplot2)
library(reshape2)
g62 <- read.csv2("g62.csv", skip = 1)
x <- g62[!colnames(g62) %in% paste0("X", 1995:2002)]
@patperu
patperu / dati_aria_toscana.R
Last active August 29, 2015 13:58
Qualità dell'aria - dati orari // Toscana
#
# Dati orari delle centraline per il monitoraggio della qualità dell'aria
# http://www.arpat.toscana.it/datiemappe/dati/qualita-dellaria-dati-orari
#
library(plyr)
options(stringsAsFactors = FALSE)
url <- "http://sira.arpat.toscana.it/sira/inspire/data/qualita_aria"
@patperu
patperu / d3_barchart_PM10.js
Last active August 29, 2015 13:59
D3 Barchart - PM10
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"> </script>
<script>
var data0 = [];
var data = [];
var jsonurl = "https://USERNAME.cloudant.com/DB/_design/myView/_view/test?group_level=2";
/* Structur {"key":[year,month],"value":[mean,lenght]}
@patperu
patperu / flare.json
Last active August 29, 2015 14:01
Simple Treemap -- Confiscati bene // see http://bl.ocks.org/mbostock/4063582
{
"name": "flare",
"children": [
{
"name": "ABRUZZO",
"children": [
{
"name": "Villa",
"size": 3
},
@patperu
patperu / import.R
Last active August 29, 2015 14:07
Import XLS via "XLConnect"
library(XLConnect)
library(jsonlite)
xcols <- c("character", rep("numeric", 6))
wb <- loadWorkbook("311_13.xls")
x <- readWorksheet(wb, sheet = "pop",
startRow = 6, startCol = 2,
endRow = 43, endCol = 8,
@patperu
patperu / day_by_week.txt
Last active August 29, 2015 14:09
Open Delays per l'Italia - Dati di ritardo
Week
Day 49 50 51 52
2014-12-02 95102 0 0 0
2014-12-03 96348 0 0 0
2014-12-04 96113 0 0 0
2014-12-05 48249 0 0 0
2014-12-06 79741 0 0 0
2014-12-07 41050 0 0 0
2014-12-08 41433 0 0 0
2014-12-09 0 96238 0 0
@patperu
patperu / write2CouchDB.R
Last active August 29, 2015 14:16
New version of 'sofa'
###############################################################
#
# Export data to a local CouchDB
#
###############################################################
library("RODBC")
#devtools::install_github("sckott/sofa")
library('sofa') # SHA: e9808c48e3ad40
library('rvest') # >= rvest 0.2.0.9000
library('dplyr')
library('stringr')
library('pbapply')
options(stringsAsFactors = FALSE)
###########################################################################################
Get_Provincia_pagine <- function() {