Learn R Programming

vvauditor (version 0.7.0)

is_unique_column: Check if a column in a dataframe has unique values

Description

Check if a column in a dataframe has unique values

Usage

is_unique_column(column_name, data_frame)

Value

TRUE if the column has unique values, FALSE otherwise.

Arguments

column_name

The name of the column to check for uniqueness.

data_frame

A dataframe containing the column to check.

Examples

Run this code
# 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

# 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

Run the code above in your browser using DataLab