Learn R Programming

DIZtools (version 1.0.3)

check_if_unique_rows: Takes a data.table dataset and checks if for each unique element in a specified column there is exaclty one row.

Description

Takes a data.table dataset and checks if for each unique element in a specified column there is exaclty one row.

Usage

check_if_unique_rows(
  data,
  colname,
  findme = NULL,
  stop = FALSE,
  feedback = TRUE,
  print_invalid_rows = TRUE,
  return = TRUE
)

Arguments

data

A data.table

colname

The name of the column to check for uniqueness.

findme

(Optional, String, default: "") Recommended with length 10. String to find the message in the code. E.g. 10-digit random hex from https://onlinetools.com/random/generate-random-hexadecimal-numbers

stop

(boolean, default = FALSE) Should the function call stop() if there are non-unique rows in the data?

feedback

(boolean, default = TRUE) Should the function print text to the console depending on the result?

print_invalid_rows

(boolean, default = TRUE) Should the function print invalid rows to the console?

return

(boolean, default = TRUE) Should the function return `TRUE` or `FALSE` depending on the result? If `stop = TRUE` is set, the function will end with `stop()` before returning anything.

Examples

Run this code
if (FALSE) {
  check_if_unique_rows(data)
}

Run the code above in your browser using DataLab