so I am trying to create a binary variable that shows whether an MP voted as their constituency did
basically meaning I want a new column if constituency voted yes and MP also votes yes (or Aye in the case of my variable) the new column shows that constituency as the MP having voted with their constituency
This is the code I have so far, but I keep getting errors, does anyone possibly know a more effective way to do this? any help greatly appreciated!
Comparison_2016_2ndRef$MP_representativeness <-if (Comparison_2016_2ndRef$Second_Ref == "Yes" & Comparison_2016_2ndRef$voteOn2Ref == "Aye") {
Comparison_2016_2ndRef$MPrepresentativeness <- "Voted With Constituency";
} else if(Comparison_2016_2ndRef$Second_Ref == "No" & Comparison_2016_2ndRef$voteOn2Ref == "No") {
Comparison_2016_2ndRef$MPrepresentativeness <- "Voted With Constituency";
} else if(Comparison_2016_2ndRef$Second_Ref == "Yes" & Comparison_2016_2ndRef$voteOn2Ref == "No") {
Comparison_2016_2ndRef$MPrepresentativeness <- "Voted Against Constituency";
} else if(Comparison_2016_2ndRef$Second_Ref == "Yes" & Comparison_2016_2ndRef$voteOn2Ref == "No"){
Comparison_2016_2ndRef$MPrepresentativeness <- "Voted Against Constituency";
}
else {Comparison_2016_2ndRef$MPrepresentativeness <- "Voted Against Constituency";}