This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Projection compatible with Google Maps | |
PROJECTION="+proj=longlat +ellps=WGS84 +no_defs +towgs84=0,0,0" | |
# wget command | |
WGET="wget -w 5 --random-wait --tries=2 -nc" | |
# The mapa digital is available as 4 files | |
declare -a extensions=(".exe" "-1.bin" "-2.bin" "-3.bin") | |
$WGET "http://internet.contenidos.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/nueva_estruc/promo/Instalador_proy_bas_inf_2017.zip" -O md.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Contact form for www.ilsevalle.com | |
// The form requieres 4 parameters: | |
// SENDGRID_API - Sendgrid API key to send emails | |
// EMAIL_SENDER - address from which the mail is sent | |
// SEND_TO - address to which the mail is sent | |
// RECAPTCHA_SECRET - Server secret from Google's recaptcha service | |
// TIMEZONE - time zone in which to display the submission time (https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) | |
const request = require('request'); | |
const sgMail = require('@sendgrid/mail'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(viridis) | |
library(ggridges) | |
library(aire.zmvm) | |
library(lubridate) | |
library(ggplot2) | |
library(dplyr) | |
library(tidyr) | |
library(stringr) | |
library(lubridate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#based on https://cran.r-project.org/web/packages/ggjoy/vignettes/gallery.html | |
library(viridis) | |
library(ggridges) | |
library(aire.zmvm) | |
library(lubridate) | |
library(ggplot2) | |
library(dplyr) | |
library(tidyr) | |
library(stringr) | |
library(lubridate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(directlabels) | |
library(ggplot2) | |
library(scales) | |
library(tidyr) | |
df = data.frame(Canada = c(522, 609, 611), | |
US = c(15872, 17793, 19362), | |
Mexico = c(20010, 20762, 24559)) | |
df = data.frame(apply(df, 2, function(x) x = x/x[1])) | |
df$year = 2014:2016 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pop <- read.csv("../downloader/data/pop_muns.csv") %>% filter(date == '2010-06-01 00:00:00') | |
mex <- injury.intent %>% | |
filter(year_reg == 2016 & intent %in% c("Homicide", "Legal Intervention")) %>% | |
group_by(state_occur_death, mun_occur_death) %>% | |
rename(state_code = state_occur_death, mun_code = mun_occur_death) %>% | |
summarise(count = n()) %>% | |
left_join(read.csv("../downloader/data/pop_muns.csv") %>% filter(date == '2016-06-01 00:00:00'), | |
by = c("state_code", "mun_code")) %>% | |
mutate(rate = count / population * 10^5) %>% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#based on https://cran.r-project.org/web/packages/ggjoy/vignettes/gallery.html | |
library(viridis) | |
library(ggridges) | |
#devtools::install_github('diegovalle/aire.zmvm') | |
library(aire.zmvm) | |
library(lubridate) | |
library(ggplot2) | |
library(dplyr) | |
library(tidyr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(readr) | |
library(ggplot2) | |
library(geofacet) | |
read_csv("https://data.diegovalle.net/elcrimen/nm-estatal-victimas.csv.gz") %>% | |
filter(subtipo == "HOMICIDIO DOLOSO") %>% | |
group_by(subtipo, state_code, state, date) %>% | |
summarise(count = sum(count, na.rm = TRUE), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(stringr) | |
library(readr) | |
library(ggplot2) | |
library(geofacet) | |
options(stringsAsFactors = FALSE) | |
mx_grid <- data.frame( | |
code = c(2L, 8L, 26L, 3L, 5L, 10L, 19L, 25L, 28L, 1L, 18L, 24L, 32L, | |
11L, 13L, 14L, 22L, 30L, 6L, 15L, 29L, 9L, 17L, 21L, 31L, 4L, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Author: Diego Valle-Jones | |
# Web: http://www.diegovalle.net | |
# Purpose: Script to download electoral shapefiles | |
# from http://cartografia.ife.org.mx/sige7/?distritacion=federal | |
set -euo pipefail | |
# Be sure to update this variable when the INE updates the shapefiles | |
DATE="13jul2016" |