check_unique_keys {metatools} | R Documentation |
Check Uniqueness of Records by Key
Description
This function checks the uniqueness of records in the dataset by key using 'get_keys' from the metacore package. If the key uniquely identifies each record the function will print a message stating everything is as expected. If records are not uniquely identified an error will explain the duplicates.
Usage
check_unique_keys(data, metacore, dataset_name = NULL)
Arguments
data |
Dataset to check |
metacore |
metacore object that only contains the specifications for the dataset of interest. |
dataset_name |
Optional string to specify the dataset. This is only needed if the metacore object provided hasn't already been subsetted. |
Value
message if the key uniquely identifies each dataset record, and error otherwise
Examples
library(haven)
library(metacore)
library(magrittr)
load(metacore_example("pilot_ADaM.rda"))
spec <- metacore %>% select_dataset("ADSL")
data <- read_xpt(metatools_example("adsl.xpt"))
check_unique_keys(data, spec)
[Package metatools version 0.1.6 Index]