I am having trouble subsetting a data.frame based on reciprocity of values in row and column.
Here is a example df to illustrate the problem:
rater <- c(21, 23, 26, 24)
ratee <- c(24, 21, 23, 21)
rating.data <- data.frame(rater, ratee)
Output:
rater ratee
1 21 24
2 23 21
3 26 23
4 24 21
I would like to subset this df by only keeping the rows that have reciprocal values.
The resulting subset should look like this:
rater ratee
1 21 24
4 24 21
Any thoughts would be much appreciated!