Skip to content

Instantly share code, notes, and snippets.

@rinze
Last active December 14, 2015 18:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rinze/5129006 to your computer and use it in GitHub Desktop.
Save rinze/5129006 to your computer and use it in GitHub Desktop.
El script que he usado para las gráficas https://twitter.com/Rinze/status/310774361588133888 y https://twitter.com/Rinze/status/310774425563836417. El segundo fichero saca https://twitter.com/Rinze/status/310779666774515714 El siguiente enlace permite acceder a los mismos datos que he usado yo (tiene información de más países, yo me he quedado c…
# Eustat data analysis
library(ggplot2)
eustat <- read.csv(file = "/tmp/ilc_di01_1_Data.csv", na.string = ":")
eustat$Value <- gsub(" ", "", eustat$Value)
eustat$Value <- as.numeric(eustat$Value)
spain <- eustat[eustat$GEO == "Spain" &
eustat$CURRENCY == "Purchasing Power Standard" &
eustat$INDIC_IL == "Top cut-off point",
c("QUANTILE", "TIME", "Value")]
spain$QUANTILE2 <- reorder(spain$QUANTILE, spain$Value, mean, na.rm = TRUE)
spain$val.first <- rep(spain[spain$TIME == 1995, "Value"],
each = length(unique(spain$TIME)))
theme_set(theme_bw())
p <- ggplot(data = spain) + geom_line(aes(x = TIME, y = Value)) +
facet_wrap(~ QUANTILE2, nrow = 2) + xlab("\nAño") +
ylab("Ingresos [PPS]\n") + ggtitle("Evolución de los ingresos en España\n1995 - 2011 (fuente: Eurostat)\n")
p
# Eustat data analysis
library(ggplot2)
eustat <- read.csv(file = "/tmp/ilc_di01_1_Data.csv", na.string = ":")
eustat$Value <- gsub(" ", "", eustat$Value)
eustat$Value <- as.numeric(eustat$Value)
spain <- eustat[eustat$GEO == "Spain" &
eustat$CURRENCY == "Purchasing Power Standard" &
eustat$INDIC_IL == "Share of national equivalised income",
c("QUANTILE", "TIME", "Value")]
spain$QUANTILE2 <- reorder(spain$QUANTILE, spain$Value, mean, na.rm = TRUE)
spain$val.first <- rep(spain[spain$TIME == 1995, "Value"],
each = length(unique(spain$TIME)))
# No hay datos de 2002, pero los de 2003 aparecen como NA. Quitar.
spain <- spain[spain$TIME != 2003, ]
theme_set(theme_bw())
p2 <- ggplot(data = spain) + geom_line(aes(x = as.numeric(QUANTILE2),
y = Value)) +
facet_wrap(~ TIME, nrow = 3) + xlab("\nDecil") + ylab("Porcentaje [%]\n") +
ggtitle("Reparto de ingresos en España\n1995 - 2011 (fuente: Eurostat)\n")
p2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment