Created
November 14, 2016 16:22
-
-
Save anonymous/80240cb93d5363f7ca5640dec144da92 to your computer and use it in GitHub Desktop.
FP - Divorce
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
#ppl divorced | |
#final project data analysis | |
install.packages('dplyr') | |
library(dplyr) | |
install.packages('readr') | |
library(readr) | |
install.packages('ggplot2') | |
library(ggplot2) | |
install.packages('RColorBrewer') | |
library(RColorBrewer) | |
install.packages('ggmap') | |
library(ggmap) | |
install.packages('maptools') | |
library(maptools) | |
install.packages('gtools') | |
library(gtools) | |
#find percentages of women in each state with a college degree or higher | |
ipumsdata_figure3 <- read_csv("~/Desktop/usa_00027 (1).csv") | |
women_only <- ipumsdata_figure3 %>% filter(SEX==2) | |
numwomen <- women_only %>% group_by(YEAR) %>% summarise(Number=sum(PERWT)) | |
women_div <- women_only %>% filter (MARST==4) | |
numwomen_div <- women_div %>% group_by(YEAR) %>% summarise(Number=sum(PERWT)) | |
joined <- left_join(numwomen,numwomen_div,by=c('YEAR'='YEAR')) | |
percentages <- joined %>% mutate(pct=Number.y/Number.x*100) | |
ggplot(data=percentages,aes(x=YEAR, y=pct)) + | |
geom_bar(stat='identity', position='dodge') + | |
labs(x='Year',y='Percent', title='Percent of Divorced Women 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() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment