Skip to content

Instantly share code, notes, and snippets.

@diegovalle
Created December 23, 2010 03:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diegovalle/752520 to your computer and use it in GitHub Desktop.
Save diegovalle/752520 to your computer and use it in GitHub Desktop.
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"))
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)
@lupevidal
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment