View source: R/R04-Data_wrangling.R
camr_missing | R Documentation |
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 ""
).
camr_missing(
x,
codes = NULL,
attribute_label = "missing",
return_codes = FALSE
)
x |
A vector of values. |
codes |
A vector of possible values
of |
attribute_label |
The label for
sublist containing codes for missing data
in the list of attributes for |
return_codes |
A logical value; if
|
A logical vector equal to TRUE
if a value is missing and FALSE
otherwise.
Kevin Potter
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.