Skip to content

Instantly share code, notes, and snippets.

@diegovalle diegovalle/conyugal.R
Last active Aug 29, 2015

Embed
What would you like to do?
Población femenina de 40 a 44 años de edad por situación conyugal
require(ggplot2)
require(reshape)
require(stringr)
require(scales)
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
0.1333900264 0.0866986092 0.1203814875 0.1677704297 0.1350452061 0.1673361018 0.1723742877 0.2003161063 0.2381625442
0.4782996145 0.6043175271 0.6266342786 0.6165165611 0.6309864938 0.6017564164 0.6192202588 0.5912486197 0.5414840989
0.2509738821 0.1739237235 0.1075405894 0.076660514 0.0937652362 0.0858057049 0.0711621725 0.0664256176 0.0792932862
0.0728234689 0.082743796 0.0742778733 0.0565067911 0.067043598 0.0648512492 0.0533251335 0.0454456882 0.0493286219
0.0085803472 0.0211338954 0.0500625047 0.06565071 0.05405914 0.0606984819 0.0678938259 0.0813648862 0.0781625442
0.0541096553 0.0306647497 0.0206597842 0.0164234987 0.0187581794 0.018952958 0.0155655628 0.0144629441 0.0132862191
", 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$conyugal <- c("Soltera",
"Casada",
"Unión libre",
"Separada",
"Divorciada",
"Viuda"
)
hom <- melt(hom, id = "conyugal")
hom$variable <- str_replace_all(hom$variable, "\\.", " ")
hom <- subset(hom, !conyugal %in% c("Casada"))
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("porcentaje")+
scale_y_continuous(limits =c(0, max(hom$value)), labels = percent) +
labs(title="Población femenina de 40 a 44 años de edad por situación conyugal (Censo 2010)")+
theme(axis.text.x=element_text(angle=-90, size = 14, vjust = .5)) +
facet_wrap(~conyugal)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.