1

I am working on a project where I am comparing the Legislative Effectiveness Scores (LES) of female house members. I am trying to determine if Democratic female House members are more effective than Republican female House members. My data includes the LES for every house member from 1973-2015. I am trying to create a plot that ONLY shows female scores, where Democrat points are blue and Republican are Red.

I found some guidance online but cannot seem to get it to work for my data. Here is what I have been trying.

pick <- function(condition){
function(gender) d %>% filter_(Female)
        }
ggplot(escores, aes(x=Year, y=LES, fill=gender))
geom_point(size = 4, shape = 4) +
  geom_point(data = pick(~party == "Democrat"), color = "blue") +
  geom_point(data = pick(~party == "Republican"), color = "red")    

Any guidance would be appreciated!

Ashley Fred
  • 11
  • 1
  • 1
  • 2
  • 4
    You need a `+` between the first `ggplot()` and `geom_point`. But also your `pick` function appears to be returning a function. It should be returning a data frame (or tibble). Also you don't seem to be using either the `contition` or `gender` parameters. Do you have a column named `Female`? It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Jun 30 '20 at 23:31

0 Answers0