camr_missing: Identify Missing Data

View source: R/R04-Data_wrangling.R

camr_missingR Documentation

Identify Missing Data

Description

Function that checks for missing values in a vector. Allows for checking against multiple different codes that denote missing values (e.g., a character vector where missing values can be either NA or "").

Usage

camr_missing(
  x,
  codes = NULL,
  attribute_label = "missing",
  return_codes = FALSE
)

Arguments

x

A vector of values.

codes

A vector of possible values of x that indicate missing data.

attribute_label

The label for sublist containing codes for missing data in the list of attributes for x.

return_codes

A logical value; if TRUE returns the set of codes for missing data actually found in the data set.

Value

A logical vector equal to TRUE if a value is missing and FALSE otherwise.

Author(s)

Kevin Potter

Examples

x <- c( NA, "", "Cat", "Dog", "Missing" )
print( camr_missing(x) )

# Custom codes
print( camr_missing(x, codes = c( NA, "Missing" ) ) )

# Codes can be saved as an attribute
x <- x |> camr_add_attribute( c( NA, "Missing" ), "missing" )
# Function can automatically access
print( camr_missing(x) )

# Can return only applicable codes for a vector
x <- c( "", "Cat", "Dog" ) # No NA values
print( camr_missing(x, return_codes = TRUE ) ) # Only "" returned


rettopnivek/camrprojects documentation built on March 26, 2024, 9:17 a.m.