Created
November 14, 2016 16:27
-
-
Save anonymous/a008a3515ebe8a4cf8668f57d212a6b4 to your computer and use it in GitHub Desktop.
FP - Percent Degrees
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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