Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Education and Religion in Mexico
library(reshape)
library(ggplot2)
library(scales)
library(stringr)
hom <- read.table(text="Total,Católica,Ortodoxos,Anabautista - Menonita,Anglicana,Bautista,Iglesia del Nazareno,Luterana,Metodista,Presbiteriana,Otras protestantes,Pentecostales,Cristianas y Evangélicas sin sustento actual pentecostal,Adventistas del Séptimo Día,Iglesia de Jesucristo de los Santos de los Últimos Días (Mormones),Testigos de Jehová,Budismo,Hinduismo,Otras Orientales,Judaica,Islámica,Raíces étnicas,Espiritualistas,Otras religiones,Sin religión,No especificado
84927468,71279088,4327,7020,2908,189744,30246,2100,20464,316260,40465,1297314,4409550,492755,245641,1228239,12673,1653,1880,53880,3226,19090,29910,12343,4008693,1217999
7855312,6692152,1902,51,1010,16587,1819,972,4486,14824,8847,35932,393181,25961,36803,52871,5810,783,691,15712,1461,1662,4100,2480,454844,80371
", sep = ",", row.names=NULL, header=TRUE,
colClasses = "numeric")
rel <- t(hom)
rel <- as.data.frame(rel)
rel$per <- rel$V2/rel$V1
rel$rel <- row.names(rel)
names(rel) <- c("total", "estudios", "per", "religion")
rel <- subset(rel, total >= 5000 & religion != "Total")
rel$religion <- str_replace_all(rel$religion, "\\.\\.", " / ")
rel$religion <- str_replace_all(rel$religion, "\\.", " ")
ggplot(rel, aes(per, reorder(religion, per))) +
geom_point(aes(size = log(estudios))) +
scale_size_area("número", breaks = log(c(5000,100000,6000000)),
labels = c(5000,100000,6000000)) +
scale_x_continuous(labels = percent) +
geom_vline(xintercept = 0.092494362, linetype = 2, color = "#666666") +
annotate("text", label = "promedio nacional", x=.19, y = "Presbiteriana",
color = "#666666") +
ggtitle("Porcentaje de adherentes mayores de 25 años con estudios profesionales,\nde maestría o doctorado (censo 2010)") +
theme_bw() +
ylab("religión")
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.