I want to select rows in which (a or b) == (c or d) without having to write out all the combinations. For example:
a b c d
1 2 3 4
1 1 2 2
1 2 1 3
2 5 3 2
4 5 5 4
df$equal <- df$a == df$c | df$a == df$d | df$b == df$c | df$b == df$d
would result in:
a b c d equal
1 2 3 4 FALSE
1 1 2 2 FALSE
1 2 1 3 TRUE
2 5 3 2 TRUE
4 5 5 4 TRUE
Is there a way to condense the statement, (a or b) == (c or d) so that one might not have to write out all four combinations? I need this for more complications situations in which there are more combinations. e.g., (a or b) == (c or d) == (e or f) == (g or h)