Skip to contents

Searches a data.frame for a column that includes 'id' in its name and is an unique identifier. Returns the index of the first column in the data.frame that meets these conditions.

Usage

find_unique_id(df)

Arguments

df

A data.frame.

Value

A numeric, indicating the index of the unique id column.

Examples

df <- data.frame(id_not_unique = rep(1, 10),
unique_id = 1:10,
also_id = 21:30,
other = letters[1:10])
find_unique_id(df)
#> [1] 2