I'm trying to create a new column in my 2016 election dataset that shows whether the candidate lost or won a county.
Democrat %>%
group_by(county) %>%
summarise(winningvote = max(fraction_votes))
This code only returns the max vote. Can I also return the candidate variable? Adding:
select(county, fraction_votes, candidate)
Doesn't return anything different.
I'll attempt to create an "outcome" variable using mutate for the last line of the code. I was thinking the apply family might be another way to solve this.
Thanks