Skip to content

Instantly share code, notes, and snippets.

/Percent Degrees

Created Nov 14, 2016
Embed
What would you like to do?
FP - Percent Degrees
#p divorced
#final project data analysis
library(dplyr)
library(readr)
library(ggplot2)
library(RColorBrewer)
library(ggmap)
library(maptools)
library(gtools)
# read csv
ipumsdata_figure3 <- read_csv("~/Desktop/usa_00028.csv")
#women only older than 22
women_only <- ipumsdata_figure3 %>% filter(SEX==2 & AGE>=22)
#total num women
numwomen <- women_only %>% group_by(YEAR) %>% summarise(tnum=sum(PERWT))
#only women with degrees
women_educ <- women_only %>% filter(EDUCD>=101 & EDUCD<=116)
#num women with degrees
numwomen_educ <- women_educ %>% group_by(YEAR) %>% summarise(num=sum(PERWT))
#join
joined <- left_join(numwomen,numwomen_educ,by=c('YEAR'='YEAR'))
#calc percent
percentages <- joined %>% mutate(pct=num/tnum*100)
ggplot(data=percentages,aes(x=YEAR, y=pct)) +
geom_bar(stat='identity', position='dodge') +
labs(x='Year',y='Percent', title='Percent of Women Holding College Degrees in the United States, 1940-2000') +
scale_y_continuous() +
theme_bw(base_size=22) +
scale_x_continuous(breaks=c(1940,1960,1980,2000)) +
scale_fill_brewer('blues')
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.