Skip to content

Instantly share code, notes, and snippets.

@diegovalle
Last active August 29, 2015 14:01
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/6c06eb205a0be589d976 to your computer and use it in GitHub Desktop.
Save diegovalle/6c06eb205a0be589d976 to your computer and use it in GitHub Desktop.
Número promedio de hijos nacidos vivos por grado de estudios
require(ggplot2)
require(reshape)
require(stringr)
hom <- read.table(text="Sin escolaridad Educación básica Educación media superior Educación superior Estudios técnicos o comerciales con preparatoria terminada Normal de licenciatura Profesional Maestría Doctorado
4.3590760723 3.271073644 2.2923336285 1.8956866673 2.1159363265 1.9962284703 1.8477515858 1.655703986 1.5113780919
", sep = "\t", row.names = NULL, header=TRUE,
colClasses = "numeric")
names(hom)[1] <- "Sin.escolaridad"
names(hom)[2] <- "Educación.básica"
names(hom)[5] <- "Estudios técnicos\no comerciales\ncon preparatoria terminada"
hom <- melt(hom)
hom$variable <- str_replace_all(hom$variable, "\\.", " ")
hom$variable <- factor(hom$variable, levels = hom$variable)
ggplot(hom, aes(variable, value, group = 1)) +
geom_line(size = 1.2) +
xlab("grado de estudios") +
ylab("número de hijos")+
ylim(0, 4.5) +
labs(title="Número promedio de hijos nacidos vivos por grado de estudios (Mujeres 40-44 años, Censo 2010)")+
theme(axis.text.x=element_text(angle=-30, size = 14, hjust=-.05))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment