check_ct_data: Check Control Terminology for a Dataset

View source: R/checks.R

check_ct_dataR Documentation

Check Control Terminology for a Dataset

Description

This function checks that all columns in the dataset only contains the control terminology as defined by the metacore specification

Usage

check_ct_data(data, metacore, na_acceptable = NULL, omit_vars = NULL)

Arguments

data

Dataset to check

metacore

metacore object that contains the specifications for the dataset of interest. If any variable has different codelists for different datasets the metacore object will need to be subsetted using select_dataset from the metacore package.

na_acceptable

logical value or character vector, set to NULL by default. NULL sets the acceptability of missing values based on if the core for the variable is "Required" in the metacore object. If set to TRUE then will pass check if values are in the control terminology or are missing. If set to FALSE then NA will not be acceptable. If set to a character vector then only the specified variables may contain NA values.

omit_vars

character vector indicating which variables should be skipped when doing the controlled terminology checks. Internally, omit_vars is evaluated before na_acceptable.

Value

Given data if all columns pass. It will 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_ct_data(data, spec)
## Not run: 
# These examples produce errors:
check_ct_data(data, spec, na_acceptable = FALSE)
check_ct_data(data, spec, na_acceptable = FALSE, omit_vars = "DISCONFL")
check_ct_data(data, spec, na_acceptable = c("DSRAEFL", "DCSREAS"), omit_vars = "DISCONFL")

## End(Not run)

pharmaverse/metatools documentation built on Jan. 24, 2025, 11:10 p.m.