Q:

Duplicate columns in dyadic-year data

As the title indicates I have a dyadic-year data. The problem is that I have (for some reason...) duplicated dyadic column names  – for example, as shown  below, A to A and B to B observations that make no sense. The real data is over 70.000 observations. 
What I want to do is to generate a dummy variable that would indicate same-same dyadic observations. 
PERSON1     PERSON2      year     
   A           A          1990    
   A           A          1991    
   A           A          1992    
   A           B          1990    
   A           B          1991    
   A           B          1992   
   A           C          1990   
   A           C          1991   
   A           C          1992    
   B           B          1990    
   B           B          1991    
   B           B          1992    
   ...

The function duplicated() doesn't help, together with other basic R commands since it's dyadic data. 
Here's the reproducible example 
structure(list(PERSON1 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L), .Label = c("A", "B", "G"), class = "factor"), 
    PERSON2 = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 
    1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 2L, 
    3L, 3L, 3L), .Label = c("A", "B", "C"), class = "factor"), 
    year = c(1990L, 1991L, 1992L, 1990L, 1991L, 1992L, 1990L, 
    1991L, 1992L, 1990L, 1991L, 1992L, 1990L, 1991L, 1992L, 1990L, 
    1991L, 1992L, 1990L, 1991L, 1992L, 1990L, 1991L, 1992L, 1990L, 
    1991L, 1992L)), .Names = c("PERSON1", "PERSON2", "year"), class = "data.frame", row.names = c(NA, 
-27L))

the desired output (duplicate dummy)
PERSON1 PERSON2 year    duplicate
A          A    1990    1
A          A    1991    1
A          A    1992    1
A          B    1990    0
A          B    1991    0
A          B    1992    0
A          C    1990    0
A          C    1991    0
A          C    1992    0
B          A    1990    0
B          A    1991    0
B          A    1992    0
B          B    1990    1
B          B    1991    1
B          B    1992    1

A:

We can do this easily by comparing 'PERSON1' with 'PERSON2'
setDT(df1)[, duplicate := as.integer(as.character(PERSON1) == as.character(PERSON2))]
 head(df1, 15)
#    PERSON1 PERSON2 year duplicate
# 1:       A       A 1990         1
# 2:       A       A 1991         1
# 3:       A       A 1992         1
# 4:       A       B 1990         0
# 5:       A       B 1991         0
# 6:       A       B 1992         0
# 7:       A       C 1990         0
# 8:       A       C 1991         0
# 9:       A       C 1992         0
#10:       B       A 1990         0
#11:       B       A 1991         0
#12:       B       A 1992         0
#13:       B       B 1990         1
#14:       B       B 1991         1
#15:       B       B 1992         1

Or using base R
transform(df1, duplicate = as.integer(as.character(PERSON1)== as.character(PERSON2)))

