Skip to content

Instantly share code, notes, and snippets.

/Divorced

Created Nov 14, 2016
Embed
What would you like to do?
FP - Divorce
#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
You can’t perform that action at this time.