Using the European Social Survey (ESS) I am trying to clean up my data in RStudio. I used paste() to combine three separate columns, prtvtDK/prtvtNO/prtvtSE (party voted for in most recent election, Denmark/Norway/Sweden respectively) into one, fullprtvt, which has about 38000 individual cases across 8 waves.
What I want to do is assign each individual a factor of either "Populist" or "Nonpopulist" depending on which party they voted for at the last election. In their data-gathering, the party names changed a few waves in so there are multiple names for the same party, but I have a list of the ones used for the populist parties that I list below:
- 'Dansk Folkeparti'
- 'Dansk Folkeparti - Danish peoples party'
- 'Sverigedemokraterna'
- 'Progress Party (FrP)'
- 'Progress Party (FRP)'
Essentially, I want anyone who voted for one of the above parties to be classified as "Populist" in the new variable. I was thinking that some kind of ifelse() function or if else statement could work, but reading through other posts I saw people suggesting using the switch() function instead. What's the best way to tackle this problem?