Learn R Programming

metatools (version 0.1.6)

check_ct_col: Check Control Terminology for a Single Column

Description

This function checks the column in the dataset only contains the control terminology as defined by the metacore specification

Usage

check_ct_col(data, metacore, var, na_acceptable = NULL)

Value

Given data if column only contains control terms. If not, will error given the values which should not be in the column

Arguments

data

Data to check

metacore

A metacore object to get the codelist from. If the variable has different codelists for different datasets the metacore object will need to be subsetted using `select_dataset` from the metacore package.

var

Name of variable to check

na_acceptable

Logical value, set to `NULL` by default, so the acceptability of missing values is 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.

Examples

Run this code
library(metacore)
library(haven)
library(magrittr)
load(metacore_example("pilot_ADaM.rda"))
spec <- metacore %>% select_dataset("ADSL")
data <- read_xpt(metatools_example("adsl.xpt"))
check_ct_col(data, spec, TRT01PN)
check_ct_col(data, spec, "TRT01PN")

Run the code above in your browser using DataLab