This question is based off two previous questions I asked on SO, each more complex than the previous. In the previous post - [How to identify mirrored duplicates of rows in R](https://stackoverflow.com/questions/54661698/how-to-identify-mirrored-duplicates-of-rows-in-r/54661800?noredirect=1#comment96114863_54661800) - 

I would like to identify "partial" matches of rows in a dataframe. Specifically, I want to create a new column with a value of TRUE if a particular row in a dataframe has duplicate row somewhere else in the dataframe based on a match between a subset of columns. An added complexity is that one of the columns in the dataframe is numeric and I want to match if the absolute values match. The issue is that I need to make sure that when a row is identified as partially duplicated, it is so ONLY if ONE of the columns that's part of the match is the mirror opposite (additive inverse) value and not just a match on an absolute value. Ultimately what I'm looking for are rows that are pairs of duplicates along 2 categorical variables and are additive inverses along a third numerical variable. To make things clearer, here's sample data:

```
name<-c("Richard Nixon", "Bill Clinton", "George Bush", "Richard Nixon", "Bill Clinton", "Richard Nixon", "Abe Lincoln","Richard Nixon", "Bill Clinton", "Richard Nixon")
state<-c("California", "Indiana", "Florida", "California", "Indiana", "California","Oregon","California", "Indiana", "California")
num<-c("-258", "123", "42", "258", "123", "-258", "87","258", "-123", "258")
date<-c("day 9", "day 2", "day 15", "day 3","day 45", "day 100", "day 99", "day 10", "day 11", "day 100")

(df <- data.frame(name, state, num, date, stringsAsFactors = FALSE))
            name      state  num    date
1  Richard Nixon California -258   day 9
2   Bill Clinton    Indiana  123   day 2
3    George Bush    Florida   42  day 15
4  Richard Nixon California  258   day 3
5   Bill Clinton    Indiana  123  day 45
6  Richard Nixon California -258 day 100
7    Abe Lincoln     Oregon   87  day 99
8  Richard Nixon California  258  day 10
9   Bill Clinton    Indiana -123  day 11
10 Richard Nixon California  258 day 100

```

If I were to run the excellent solution from the previous SO question I posted, it would result in the following

```
(df %>%
    mutate(num = as.numeric(num), num1 = abs(num)) %>% 
    group_by(name, state, num1) %>% 
    mutate(newcol = n() > 1 & n_distinct(sign(num)) > 1) %>%
    ungroup %>% 
    select(-num1)) %>%
    arrange(name)
# A tibble: 10 x 5
   name          state        num date    newcol
   <chr>         <chr>      <dbl> <chr>   <lgl> 
 1 Abe Lincoln   Oregon        87 day 99  FALSE 
 2 Bill Clinton  Indiana      123 day 2   TRUE  
 3 Bill Clinton  Indiana      123 day 45  TRUE  
 4 Bill Clinton  Indiana     -123 day 11  TRUE  
 5 George Bush   Florida       42 day 15  FALSE 
 6 Richard Nixon California  -258 day 9   TRUE  
 7 Richard Nixon California   258 day 3   TRUE  
 8 Richard Nixon California  -258 day 100 TRUE  
 9 Richard Nixon California   258 day 10  TRUE  
10 Richard Nixon California   258 day 100 TRUE

```

The problem with above output is that for Richard Nixon and for Bill Clinton there is one row too many where TRUE appears. My desired output is the following:

```
   name          state        num date    newcol
 1 Abe Lincoln   Oregon        87 day 99  FALSE 
 2 Bill Clinton  Indiana      123 day 2   TRUE
 3 Bill Clinton  Indiana      123 day 45  FALSE
 4 Bill Clinton  Indiana     -123 day 11  TRUE  
 5 George Bush   Florida       42 day 15  FALSE 
 6 Richard Nixon California  -258 day 9   TRUE  
 7 Richard Nixon California   258 day 3   TRUE  
 8 Richard Nixon California  -258 day 100 TRUE  
 9 Richard Nixon California   258 day 10  TRUE  
10 Richard Nixon California   258 day 100 FALSE

```

Notice how only rows where a mirrored match -mirrored match in the sense that the rows are duplicates except that they're additive inverses of one another for the column `num`. So im basically trying to identify all rows that match along the `name` and `state` variables and are additive inverses of each other along the `num` variable, with the condition that the additive inverses be unique -unique in the sense that `num` should only be considered an additive inverse of no more that one other row. 

**For additional clarity if above explanation needs clarification, otherwise skip:**

So some process that loops through each row identifying the first row that meets the criteria of being a partial match (partial in the sense of absolute value / additive inverse) and then assigns a TRUE to those two rows and then moves on to the next observation and so on. For example, the code could begin with Abe Lincoln and run through each subsequent rows until a partially matched row is found, if no row is found then in the column `newcol` `FALSE` is the value that should be generated. Then it moves on to Bill Clinton, Indiana, 123 and runs through the rows to identify a partial match. The next row is NOT a partial match b/c 123 and 123 are not partial matches (they are full matches), but the following row is a partial match (123 and -123), resulting in the value of `TRUE` being generated for `newcol` for that observation as well as the partially matched row. Then it goes on to the third row (Bill Clinton, Indiana, 123). The important part by this step is that if a row already has a value for `newcol` the loop need not run through it. So for that row (the third row), the loop would skip the first row (with Abe Lincoln) b/c that already has a value of `FALSE` and it would skip the second row and 4th rows bc those two were already matched together, resulting in a `FALSE` for the third row b/c no remaining rows partially matched and the only partial match in the data frame was already matched with another inverse.