Skip to content

Instantly share code, notes, and snippets.

@aniversarioperu
Created November 3, 2013 18:08
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 aniversarioperu/7292990 to your computer and use it in GitHub Desktop.
Save aniversarioperu/7292990 to your computer and use it in GitHub Desktop.
Plot del total de delitos por año para Perú. Datos tomados del INEI: http://www.inei.gob.pe/media/MenuRecursivo/Cap08005.xls
library(ggplot2)
y <- read.csv("datos.txt", header=FALSE)
y <- as.vector(y[,1])
x <- 2005:2012
int <- lsfit(x,y)$coefficients[1]
slope <- lsfit(x,y)$coefficients[2]
p <- ggplot(,aes(x,y))
p + geom_point() + geom_abline(intercept=int, slope=slope) +
labs(title = "Perú: Número total de delitos por año")
summary(lm(x ~ y))
# R2 = 0.67
# p-value = 0.008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment