is_unique_column.Rd
Check if a column in a dataframe has unique values
is_unique_column(column_name, data_frame)
The name of the column to check for uniqueness.
A dataframe containing the column to check.
TRUE
if the column has unique values, FALSE
otherwise.
# Create a dataframe with a unique ID column
data_frame <- tibble::tibble(
id = c(1, 2, 3, 4, 5),
value = c("a", "b", "c", "d", "e")
)
is_unique_column("id", data_frame) # Returns TRUE
#> [1] TRUE
# Create a dataframe with duplicate values in the ID column
data_frame <- tibble::tibble(
id = c(1, 2, 3, 4, 5, 1),
value = c("a", "b", "c", "d", "e", "a")
)
is_unique_column("id", data_frame) # Returns FALSE
#> [1] FALSE