I am have a dataframe that has, among others, two columns: clean.data$bilateral and clean.data$if.bilateral.other.party. Inside the bilateral data, there are three observations: Y, N, and Bilateral (yes, I know the observation is basically the same as the column name and that this is bad. The observation is capitalized, whereas the column name is not).
clean.data <- data.frame("bilateral" = c("Y", "Bilateral", "N", "Y", "Bilateral", "N"),
       "if.bilateral.other.party" = c("Jordan", "Sweeden", NA, "Uk,Netherlands", "Russia,Poland", "NewZealand"))
Treaties that are Bilateral or Y should only have one observation in if.bilateral.other.party, however some don't. For example, Uk,Netherlands should not be listed as Bilateral, instead it should be N. I've already removed spaces in the if.bilateral.other.party column, and there are commas between parties.
I am trying to identify observations that are currently marked as Bilateral or Y that should not be, and change the observation to N in that case. I also need to do the reverse, changing observations N to Y if they have other parties listed.
How do I do this?
 
    