Construct table of missing values codes and their meaning
write_missing_values.Rd
The write_missing_values function reads an entity's attribute details from a "entity name"_attrs.yaml or "entity name"_attrs.csv file in the working directory - the details of which are incorporated into the EML metadata for that entity. If present in the working directory, factor metadata in a "entity name"_factors.yaml or "entity name"_factors.csv are read and incorporated into attribute metadata.
Arguments
- storage
(charcter) write_missing_values stores output in a tibble or dataframe. The object should be emtpy and consist of three columns (attributeName (character), code (character), and definition (charcater)). The user should create this object prior to running the function and pass the unquoted name of the object to write_missing_values via the storage parameter.
- dataObject
(character) The unqouted name of the data entity that will be examined for missing values.
- field
(character) The quoted name of the field within the data entity that will be examined for missing values.
- MVC
(optional) (character) If relevant, the quoted name of a missing value code other than NA or NaN that should be documented.
Value
A tibble documenting the presence of NA, NaN, or a user-specified missing value code for the field of a tibble or dataframe.
Details
The write_missing_values function reads an entity's attribute details from a "entity name"_attrs.yaml or "entity name"_attrs.csv file in the working directory - the details of which are incorporated into the EML metadata for that entity. If present in the working directory, factor metadata in a "entity name"_factors.yaml or "entity name"_factors.csv are read and incorporated into attribute metadata.
Note
The write_missing_values function is intended primarily as a helper to other functions in the capeml ecosystem so is not meant to be called directly (but can be).
Examples
if (FALSE) { # \dontrun{
missing_value_frame <- tibble::tibble(
attributeName = as.character(),
code = as.character(),
definition = as.character()
)
write_missing_values(
storage = missingValueFrame,
dataObject = captures,
field = "weight",
MVC = "X"
)
# write_missing_values can be run on a single field (as above) of a data
# object but the most common use case, and how it is applied in the capeml
# ecosystem, is to loop over all fields in a data entity (sensu with purrr
# below).
purrr::map_df(
.x = colnames(data_entity),
.f = capeml::write_missing_values,
storage = missing_value_frame,
dataObject = data_entity,
MVC = "X"
)
} # }