heims (version 0.4.0)

element_validation: Validate HEIMS elements

Description

Return TRUE or FALSE on whether or not each variable in a data.table complies with the HEIMS code limits

Usage

validate_elements(DT, .progress_cat = FALSE)

prop_elements_valid(DT, char = FALSE)

count_elements_invalid(DT, char = FALSE)

Arguments

DT

The data.table whose variables are to be validated.

.progress_cat

Should the progress of the function be displayed on the console? If TRUE the name of the element about to be validated is shown.

char

Return as character vector, in particular marking -- any complete or completely absent values.

Value

A named logical vector, whether or not the variable complies with the style requirements. A value of NA indicates the variable was not checked (perhaps because it is absent from heims_data_dict).

Details

For early detection of invalid results, the type of the variable (in particular integer vs double) is considered first, vetoing a TRUE result if different.

Examples

Run this code
# NOT RUN {
X <- data.frame(E306 = c(0, 1011, 999, 9998))
validate_elements(X)  # FALSE
prop_elements_valid(X)
X <- data.frame(E306 = as.integer(c(0, 1011, 999, 9998)))
validate_elements(X)  # TRUE

# }

Run the code above in your browser using DataLab