Create your dependent variable

Create the dependent variable

Our dependent variable is a dichotomous, dummy variable where \(1\) means that the respondent voted for the party in government - this is what we are trying to explain- and \(0\) means that they voted for another party.

eco_voting<-eco_voting %>% mutate(incumbent=case_when(b02==2~1, b02==1~0, b02>=3~0)) 

You may use the table() function to double check the new variable entitled `incumbent’:

table(eco_voting$b02)
## 
##   0   1   2   3   4   5   6   7 
##   2 457 347  48  49   1  19  21
table(eco_voting$incumbent)
## 
##   0   1 
## 595 347