I am using a national survey to run an econometric analysis in R.

The df is based on a survey which is conducted every two years: some families have been interviwed for more than one times, and others appear just one time.

The variable family represents the code number of the family, the variable nord the code number of the componenet of the family in a certain year; the variable nordp represents the code number that the individual had in the previous survey. So when individuals are interwied more than one time nord and nordp shuold be the same, but actually it is not always true. 

I need to filter the df in order to have only the individual that appears at least one time:

```
df <- df %>%
group_by(nquest, nordp) %>%
filter(n()>1)

```

Then I assign a unique id value to each individual with this command (in different years I have the same id for the same couple of nquest and nord):

```
df <- transform(df, id=as.numerica(interaction(nquest, nord))

```

the problem is that sometime the data were introduce in a wrong way so that in one year the same individual (identified with the same nquest and nordp) actually is not really the same person; for example look at the two lines with \*\*; they have the same nquest and nordp, and so the same id, but they are not the same person (nord is not the same, and also sex is different). 

```
  year id nquest nord nordp sex
**2000  1     10    1     1   F**
  2000  2     20    1     1   M
  2000  3     30    1     1   M
  2002  1     10    1     1   F
  2002  2     20    1     1   M
  2002  4     40    1     1   F
**2004  1     10    2     1   M**
  2004  2     20    1     1   M
  2004  3     30    1     1   M

```

so my problem is eliminate the observations that are not really the same using sex as check variable; consider that the df is composed by more than 50k observations and so I can't check for each id. 

Thank you in advance