Learn R Programming

metatools (version 0.1.6)

check_unique_keys: 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)

Value

message if the key uniquely identifies each dataset record, and error otherwise

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.

Examples

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

Run the code above in your browser using DataLab