Extract unique values from an excel

I have 19396 observations in my excel but most of them are duplicated values.
I want to extract only the unique ones from the column that identifies them (national identificacion code) with all the others variables from the other columns.

For example:
Citizen National code
|Citizen 1| |18148807|

|Citizen 2| |18148807|

Citizen 3 18816237

Citizen 4 18816237

Citizen 5 19028249
Citizen 6 19028249

As you can see some of this citizen are duplicated and are the same people.
So I wanted to extract only the unique values from national code with all the others variables as well.

Here's a very SQLish way to do it:

df1 <- data.frame(
     citizen = c('citizen 1', 'citizen2', 'citizen 3', 'citizen 1'),
    national_id = c(1, 2, 3, 1)

unique_ids_df <- distinct(df1, national_id)

all_uniques <- inner_join(unique_ids_df, df1, by = 'national_id')

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.