Created
October 19, 2022 23:06
-
-
Save ryanburge/a86b9ff812fc4cc4e94bf4b109030a61 to your computer and use it in GitHub Desktop.
Code from Day One
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
cces20 %>% ct(gender) | |
## THIS IS A COMMENT | |
cces20 %>% ct(race) | |
## HOW MANY 25 YEAR OLDS #### | |
cces20a <- cces20 %>% | |
mutate(age = 2020 - birthyr) | |
cces20 %>% | |
ct(sexuality, show_na = FALSE) | |
cces20 %>% | |
filter(race == 2) %>% | |
filter(sexuality != 1) %>% | |
ct(gender) | |
cces20 %>% | |
filter(race == 1 | race == 3) %>% | |
ct(gender) | |
cces20 %>% | |
filter(race == 3) %>% | |
mutate(age = 2020 - birthyr) %>% | |
filter(age < 35) %>% | |
ct(gender) | |
## COUNT THE GENDER OF HISPANIC PEOPLE UNDER THE AGE OF 35 ### | |
age <- cces20 %>% | |
mutate(age = 2020 - birthyr) %>% | |
ct(age) | |
age %>% | |
ggplot(., aes(x = age, y = pct)) + | |
geom_col(fill = "hotpink") + | |
labs(x = "Age", y = "") | |
## CREATE A BAR GRAPH OF RELIGIOUS ATTENDNACE FOR MEN #### | |
att <- cces20 %>% | |
filter(gender ==1) %>% | |
filter(attend <= 6) %>% | |
mutate(attend = 7 - attend) %>% | |
ct(attend) | |
att %>% | |
ggplot(., aes(x = attend, y = pct)) + | |
geom_col(fill = "hotpink", color= "black") + | |
scale_y_continuous(labels = percent) + | |
labs(caption = "DATA: CCES 2020") + | |
theme_fivethirtyeight() | |
attm <- cces20 %>% | |
filter(gender ==1) %>% | |
filter(attend <= 6) %>% | |
mutate(attend = 7 - attend) %>% | |
ct(attend) %>% | |
mutate(type = "Men") | |
attf <- cces20 %>% | |
filter(gender ==2) %>% | |
filter(attend <= 6) %>% | |
mutate(attend = 7 - attend) %>% | |
ct(attend) %>% | |
mutate(type = "Women") | |
graph <- bind_rows(attm,attf) | |
graph %>% | |
ggplot(., aes(x = attend, y = pct, fill = type)) + | |
geom_col(color= "black") + | |
scale_y_continuous(labels = percent) + | |
facet_wrap(~ type) + | |
labs(caption = "DATA: CCES 2020") + | |
theme_minimal() + | |
theme(legend.position = "none") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment