Created
December 23, 2010 03:35
-
-
Save diegovalle/752520 to your computer and use it in GitHub Desktop.
Problems with the Mexican mortality database
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(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")) | |
ggplot(m.ah, aes(Date, value, group = variable, | |
color = variable)) + | |
geom_line(size = 1.2) + | |
xlab("date") + | |
ylab("number of deaths") + | |
opts(title = "Deaths by Homicide or Accident in the Municipality of Chenalhó (1997-1998)") + | |
scale_colour_hue("type of\ndeath") + | |
annotate("text", x=as.Date("1997-12-23"), y = 46, | |
label = "The acteal massacre occurred\non December 22, 1997", hjust = 0) | |
dev.print(png, "acteal.png", width = 700, height = 500) | |
juarez <- read.csv("http://spreadsheets.google.com/pub?key=0AjjLwVYbDGx7dFdXbHFnS1lqM1drUE84NGtmeTBxQVE&hl=en&single=true&gid=0&output=csv") | |
juarez$per <- juarez$Lesions / juarez$Total | |
ggplot(subset(juarez, Year >= 1994), aes(Year, per)) + | |
geom_line(size = 1.2) + | |
scale_y_continuous(formatter = "percent") + | |
opts(title = "Fatal Lesions of Unknown Intent as a Percentage of Homicides") + | |
ylab("percentage") + xlab("year") | |
dev.print(png, "juarez-lesions.png", width = 700, height = 500) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Estimado Diego
Esta muy interesante la sintaxis, una consulta ¿haz corregido las base de datos de mortalidad tomando en cuenta las reglas de CIE 10?
Mi pregunta va porque actualmente me encuentro estableciendo consistencia en la base de datos de mortalidad o sea aplicando las regla de modficacion de mortalidad. La experiencia que haz adquirido me va ser de utilidad para avanzar con mis labores. mi correo es lupe.vidal7@gmail.com
Muy agradecido por tu respuesta