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 = deprecated())

Arguments

data

Dataset to check

metacore

metacore object that only contains the specifications for the dataset of interest.

dataset_name

[Deprecated] Optional string to specify the dataset that is being built. This is only needed if the metacore object provided hasn't already been subsetted.
Note: Deprecated in version 0.2.0. The dataset_name argument will be removed in a future release. Please use metacore::select_dataset to subset the metacore object to obtain metadata for a single dataset.

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.2.0 Index]