Takes a data.table dataset and checks if for each unique element in a specified column there is exaclty one row.
check_if_unique_rows(
data,
colname,
findme = NULL,
stop = FALSE,
feedback = TRUE,
print_invalid_rows = TRUE,
return = TRUE
)A data.table
The name of the column to check for uniqueness.
(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
(boolean, default = FALSE) Should the function call
stop() if there are non-unique rows in the data?
(boolean, default = TRUE) Should the function print text to the console depending on the result?
(boolean, default = TRUE) Should the function print invalid rows to the console?
(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.
if (FALSE) {
check_if_unique_rows(data)
}
Run the code above in your browser using DataLab