Learn R Programming

rcoder (version 0.3.0)

matches_coding: Checks if vector's content adheres to a coding

Description

Performs to check to see if the set of vector values are equal to or a subset of a coding's values.

Usage

matches_coding(vec, coding, ignore_empty = TRUE)

verify_matches_coding(vec, coding, ignore_empty = TRUE)

Value

TRUE/FALSE

Arguments

vec

A vector

coding

A `coding` object

ignore_empty

Logical flag to skip check if coding is empty

Functions

  • verify_matches_coding(): Rather than returning TRUE/FALSE, this function halts execution if `matches_coding()` returns FALSE.

Examples

Run this code
vec1 <- sample(1:2, 10, replace = TRUE)
vec2 <- sample(0:1, 10, replace = TRUE)
cdng <- coding(code("Yes", 1), code("No", 0))
matches_coding(vec1, cdng)
matches_coding(vec2, cdng)

Run the code above in your browser using DataLab