Your objective is to replicate these figures, created using the Center of Legislative Effectiveness Data. These figures are similar to those we completed in the lecture videos.
IMPORTANT: Filter your data so you are only displaying information for the 115th Congress.
Hints:
For the y-axis, use the variable “all_pass”.
For the x-axis, use the variable “dwnom1”.
Make sure you recode the data for the “female” variable and rename it as “Gender” to generate the correct labels for the legend.
Set the color aesthetic in the ggplot() function to make the color of the dots change based on Gender.
Make sure the axis labels are correct.
cel %>% filter(congress==115) %>%
rename("Gender" = female) %>%
mutate(Gender = case_when(
Gender == 0 ~ "Male",
Gender == 1 ~ "Female"
)) %>%
ggplot(aes(x=dwnom1,y=all_pass,colour=Gender)) + geom_point() +
xlab("Ideology") +
ylab("Bills Passed")
Hints:
For the x-axis, use the variable “votepct”.
For the y-axis, use “all_pass”.
Make sure you recode the data for the “female” variable to generate the correct labels for the legend. Rename that column “Gender”. (you may have already done this in the last exercise)
Make sure you recode the data for “majority” variable to generate the correct labels of the facetted figures.
Set the color aesthetic in the ggplot() function to make the color of the dots change based on Gender.
Use scale_color_manual() to set the colors to green for males and orange for females.
Make sure the axis labels are correct.
cel %>% filter(congress==115) %>%
rename("Gender" = female) %>%
mutate(Gender = case_when(
Gender == 0 ~ "Male",
Gender == 1 ~ "Female"
)) %>%
mutate(majority = case_when(
majority == 0 ~ "Minority",
majority == 1 ~ "Majority"
)) %>%
ggplot(aes(x=votepct,y=all_pass,colour=Gender)) + geom_point() +
xlab("Vote Percentage") +
ylab("Bills Passed") +
facet_wrap(~majority) +
scale_color_manual(values=c("Female"="orange","Male"="green"))
Hints:
For the y-axis, use the variable “les”.
Make sure you recode the data for the “majority” variable to generate the correct labels. (you may have already done this in the last exercise)
Make sure the axis labels and figure title are correct.
cel %>% filter(congress==115) %>%
mutate(majority = case_when(
majority == 0 ~ "Minority",
majority == 1 ~ "Majority"
)) %>%
ggplot(aes(x=majority,y=les)) + geom_boxplot() +
xlab("Majority or Minority") +
ylab("Legislative Effectiveness") +
ggtitle("LES in the 115th Congress")