Skip to content

Instantly share code, notes, and snippets.

@diegovalle
Created October 20, 2010 01:10
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/635565 to your computer and use it in GitHub Desktop.
Save diegovalle/635565 to your computer and use it in GitHub Desktop.
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)
ggplot(hom, aes(factor(year), updates, group = 1)) +
scale_colour_discrete("Source") +
geom_line(aes(color = "SNSP")) +
geom_line(aes(factor(year), original, color = "SNSP"),
linetype = 2) +
geom_point(aes(factor(year), inegi, color = "INEGI")) +
ylim(0, max(update)) +
xlab("year") +
ylab("number of homicides") +
opts(title = "Discrepancies in Homicide Data for the State of Chihuahua") +
annotate("text", x = "2009", y = 2523, label = "original SNSP",
hjust = 0) +
annotate("text", x = "2009", y = 3156, label = "updated SNSP",
hjust = 0) +
annotate("text", x = "2008", y = 2567, label = "INEGI",
hjust = 1.06)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment