Skip to content

Instantly share code, notes, and snippets.

View diegovalle's full-sized avatar

Diego Valle-Jones diegovalle

View GitHub Profile
@diegovalle
diegovalle / cheaters.r
Last active September 4, 2015 10:34
Corruption indicators and their correlations
########################################################
##### Author: Diego Valle Jones
##### Website: www.diegovalle.net
##### Date Created: Thu Feb 18 19:34:27 2010
########################################################
#Corruption indicators and their correlations
library(ggplot2)
grid.newpage()
@diegovalle
diegovalle / gdp.r
Created February 25, 2010 03:34
Pretty plots of Mexico's gdp
########################################################
##### Author: Diego Valle Jones
##### Website: www.diegovalle.net
##### Date Created: Mon Feb 22 19:11:54 2010
########################################################
#Pretty plots of Mexico's gdp
library(ggplot2)
#deseasonalized quarterly gdp 1993-2009 in 2003 pesos
@diegovalle
diegovalle / diet.r
Created March 9, 2010 17:18
Cluster analysis of what the world eats
########################################################
##### Author: Diego Valle Jones
##### Website: www.diegovalle.net
##### Date Created: Mon Mar 01 18:51:27 2010
########################################################
#1. For what foods are Americans and Mexicans outliers
#2. Partition the data around medoids to classify the
#countries of the world according to what they eat
library(ggplot2)
@diegovalle
diegovalle / juarez-vs-chihuahua.r
Created June 21, 2010 00:40
Compare the SNSP homicide data for Chihuahua
########################################################
##### Author: Diego Valle Jones
##### Website: www.diegovalle.net
##### Date Created: Sun Jun 20 20:30:49 2010
########################################################
#Compare the SNSP homicide data for Chihuahua
library(ggplot2)
#Chihuahua 2008: 1,414 - SNSP data http://www.icesi.org.mx/documentos/estadisticas/estadisticas/denuncias_homicidio_doloso_1997_2008.xls
#Cd. Juarez 2008: 1653 - http://www.google.com/hostednews/afp/article/ALeqM5g2iONUbtwl8in-a_sCMRSmoX8veA
@diegovalle
diegovalle / hispanics-vs-mexicans.r
Created July 9, 2010 20:30
Homicide in Mexico, the US and Canada
########################################################
##### Author: Diego Valle Jones
##### Website: www.diegovalle.net
##### Date Created: Tue Jul 13 11:02:59 2010
########################################################
#1. -Compare homicide rates according Vital Statistics in the US (Hispanics) and in Mexico
#2.- Homicides in the three North American coutries
#Sources:
#INEGI Estadísticas Vitales for Mexico - http://github.com/diegovalle/Homicide-MX-Drug-War
@diegovalle
diegovalle / cisen.r
Created August 4, 2010 20:43
Plot CISEN execution data and compare it to that reported by Milenio
#Plot CISEN execution data and compare it to that reported by Milenio
library(ggplot2)
execu <- read.csv("http://spreadsheets.google.com/pub?key=0AjjLwVYbDGx7dGl3VVRza3JJT3pLQlBqZVNVUGh6SHc&hl=en&single=true&gid=0&output=csv")
mexecu <- melt(execu[3:6], id = c("Year","Month"))
mexecu$date <- as.Date(paste(mexecu$Year, mexecu$Month, "15",
sep = "-"),
format = "%Y-%b-%d")
ggplot(mexecu, aes(date, value, group = variable, color = variable)) +
@diegovalle
diegovalle / narco-killings.R
Created October 14, 2010 01:14
Narco killings map of Mexico
#Download the narco killings map compiled by Walter Mckay available
#at LEAP Mexico https://sites.google.com/site/policereform/leap-mexico/narco-killings
library(rgdal)
library(gtools)
library(maptools)
library(ggplot2)
library(maps)
library(Cairo)
library(stringr)
library(MASS)
@diegovalle
diegovalle / 2009-update.R
Created October 20, 2010 01:10
Chart of the number of homicides in Chihuahua
library(ggplot2)
update <- c(2030, 3156)
original <- c(1414, 2523)
inegi <- c(2567, NA)
hom <- data.frame(year = 2008:2009,
updates = update,
original = original,
inegi = inegi)
@diegovalle
diegovalle / acteal.R
Created December 23, 2010 03:35
Problems with the Mexican mortality database
library(ggplot2)
library(stringr)
ah <- read.csv("http://spreadsheets.google.com/pub?key=0AjjLwVYbDGx7dGNxV0FOd3c4a3hxa2FkTEh5QS0wX2c&hl=en&single=true&gid=0&output=csv")
ah$mon.num <- 1:12
ah$Year <- rep(1997:1998, each = 12)
ah$Date <- as.Date(str_c(ah$Year, ah$mon.num, "15", sep = "-"))
m.ah <- melt(ah[c(2,3,6)], id = c("Date"))
@diegovalle
diegovalle / drug-war-dates.yaml
Created February 2, 2011 00:37
Important dates in the Mexican drug war (joint ops, captures, etc)
R.C.Assassination:
Rodolfo Carrillo Fuentes Assassination: 2004-09-11
source: http://www.noroeste.com.mx/publicaciones.php?id=409384
Fox.Troops.NL:
Troops in Nuevo Laredo: 2005-06-13
source: http://www.univision.com/content/content.jhtml?cid=625397
Op.Michoacan:
Operation Michoacan: 2006-12-11