% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checks.R
\name{check_ct_data}
\alias{check_ct_data}
\title{Check Control Terminology for a Dataset}
\usage{
check_ct_data(
  data,
  metacore,
  na_acceptable = NULL,
  omit_vars = NULL,
  verbose = "message"
)
}
\arguments{
\item{data}{Dataset to check}

\item{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
\code{select_dataset} from the metacore package.}

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

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

\item{verbose}{\code{character} string controlling the verbosity of the output.
Possible values are \code{"message"} (for general information and success messages)
and \code{"warn"} (for warnings). Partial matching is allowed.
\strong{Important}: \code{"silent"} is explicitly \strong{not} a valid option for \code{verbose} in
this function. The primary purpose of \code{check_ct_data} is to identify and
warn the user about non-compliant or problematic control terminology. Allowing
the suppression of these warnings would bypass the function's intent and could
lead to unnoticed data quality issues. If \code{verbose = "silent"} is provided, it will
be coerced to \code{"message"} with a warning.}
}
\value{
Given data if all columns pass. It will issue a warning otherwise.
}
\description{
This function checks that all columns in the dataset only contains the
control terminology as defined by the metacore specification.
}
\examples{
library(haven)
library(metacore)
library(magrittr)
load(metacore_example("pilot_ADaM.rda"))
spec <- metacore \%>\% select_dataset("ADSL", quiet = TRUE)
data <- read_xpt(metatools_example("adsl.xpt"))

check_ct_data(data, spec, omit_vars = c("AGEGR2", "AGEGR2N"))
\dontrun{
# 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")
}
}
