Skip to content

Instantly share code, notes, and snippets.

Diego Valle-Jones diegovalle

Block or report user

Report or block diegovalle

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@diegovalle
diegovalle / privacy_policy_blogdiegovallenet.md
Last active May 27, 2018
Privacy policy for blog.diegovalle.net
View privacy_policy_blogdiegovallenet.md

Privacy Policy

Last revised on 2018-05-18

www.diegovalle.net, blog.diegovalle.net Privacy Policy

This Privacy Policy describes how your personal information is collected, used, and shared when you visit or make a purchase from www.diegovalle.net or blog.diegovalle.net (the “Site”).

PERSONAL INFORMATION WE COLLECT

@diegovalle
diegovalle / first-nation-homicides.R
Created Jun 19, 2015
Aboriginal (Canada) and American Indian or Alaska Native (U.S.A.) homicide rates
View first-nation-homicides.R
library("ggplot2")
library("gridExtra")
addSource <- function(plot, text = "") {
plot <- arrangeGrob(plot,
sub = textGrob(text,
x = 0, hjust = -0.1, vjust=0.1,
gp = gpar(fontface = "italic", fontsize = 9,
col = "gray30")))
return(plot)
View election2015.R
library(ggplot2)
library(dplyr)
library(readr)
library(rgeos)
library(maptools)
library(rgdal)
library(scales)
library(downloader)
#Download the latest version of the PREP
@diegovalle
diegovalle / mx_hexgrid.json
Created May 15, 2015
Hex Grid of Mexican States
View mx_hexgrid.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@diegovalle
diegovalle / homicides-2013.Rmd
Last active Aug 1, 2018
changes and trends in homicide rates in the most violent metro areas or big municipios or at the national level
View homicides-2013.Rmd
---
title: "Changes in homicide rates"
output: html_document
---
I've updated the [mxmortalitydb](https://github.com/diegovalle/mxmortalitydb) package to include 2013 data. This data only packages includes all injury intent deaths (accidents, homicides, suicides and unspcified intent) that were registered in Mexico from 2004 to 2013. You can use the package to calculate changes and trends in homicide rates in the most violent metro areas or big municipios.
```{r}
#if (!require('devtools')) install.packages('devtools')
@diegovalle
diegovalle / ageb0.json
Last active Aug 29, 2015
Nobody lives here
View ageb0.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View privacy_policy.markdown

Privacy Policy

Last revised on 2015-08-16

The Gist

hoyodecrimen will collect certain non-personally identify information about you as you use our sites. We may use this data to better understand our users. We can also publish this data, but the data will be about a large group of users, not individuals.

We will also ask you to provide personal information, but you'll always be able to opt out. If you give us personal information, we won't do anything evil with it.

View json_to_csv.R
library("jsonlite")
library("dplyr")
library("magrittr")
library("stringr")
rnpe_c <- fromJSON('rnped_comun.json')
rnpe_c <- as.data.frame(rnpe_c$aaData, stringsAsFactors = FALSE)
rnpe_c$date <- as.Date(rnpe_c$fuerocomun_desapfecha, "%d/%m/%Y")
rnpe_c$tipo <- "comun"
rnpe_c$fuerocomun_desapentidad %<>% str_replace_all(" DE ZARAGOZA|ESTADO DE ", "")
View gist:8c8ce89af5efec8d14f6
--cuadrantes
with crimes as
(select sum(count) as count,sector,cuadrante,max(population)as population, crime from cuadrantes where date >= '2013-08-01' and date <= '2014-07-01' group by cuadrante, sector, crime)
SELECT * from (SELECT count,crime,sector,cuadrante,rank() over (partition by crime order by count desc) as rank,population from crimes group by count,crime,sector,cuadrante,population) as temp2 where rank <= (SELECT rank from (SELECT count,cuadrante,rank() over (partition by crime order by count desc) as rank, row_number() OVER (ORDER BY count desc) AS rownum from crimes) as rank10 where rownum = 10) order by crime, rank,sector, cuadrante
--sectores
with crimes as
(select (sum(count) / (sum(population) /12 )* 100000) as rate,sum(count) as count,sector,sum(population)/12 as population, crime from cuadrantes where date >= '2013-08-01' and date <= '2014-07-01' group by sector, crime)
SELECT * from (SELECT count,rate,crime,sector,rank() over (partition by crime order by rate desc) as rank,population f
View gist:0cf879df4e57359177f1
Verifying that +diegovalle is my Bitcoin username. You can send me #bitcoin here: https://onename.io/diegovalle
You can’t perform that action at this time.