| Title: | Build a Data Dictionary for Use with QAQC |
|---|---|
| Description: | Builds concept lookup tables from Connect data dictionaries to support quality assurance and quality control workflows. Combines concept identifiers and definitions across dictionary columns, removes duplicate entries and records with missing identifiers, and reports conflicting definitions for review. |
| Authors: | Daniel Russ [aut, cre] |
| Maintainer: | Daniel Russ <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.0.9000 |
| Built: | 2026-10-05 16:29:23 UTC |
| Source: | https://github.com/danielruss/qcdd |
Combine paired concept ID and definition columns into a two-column tibble. Column pairs are matched by position and must have equal lengths.
add_concept_ids(df, concept_ids, definitions)add_concept_ids(df, concept_ids, definitions)
df |
A data frame or other object convertible to a tibble containing the dictionary columns. |
concept_ids |
Bare concept ID column names, supplied as a single name
or combined with |
definitions |
Bare definition column names, supplied as a single name
or combined with |
Identical ID-definition pairs and rows with missing concept IDs are removed after combining all column pairs. If an ID has conflicting definitions, a warning is issued and the first occurrence is retained, using column-pair order followed by input row order. Missing definitions are retained and may be selected as the first occurrence. When conflicts are found, the result is ordered by the concept ID groups.
A tibble with concept_id and definitions columns and one row
per non-missing concept ID. Conflicting definitions are stored in the
CID_warning attribute and can be retrieved with cid_warning().
Retrieve the conflict report stored by add_concept_ids() without issuing
another warning or modifying the lookup.
cid_warning(df)cid_warning(df)
df |
A concept lookup returned by |
A tibble with concept_id and definitions columns containing
the distinct conflicting ID-definition pairs, including the definitions
retained in the lookup. Returns NULL if the CID_warning attribute
is absent, as when no conflicts were found.
Load the dictionary
load_dictionary_file(path, ...)load_dictionary_file(path, ...)
path |
Path to the dictionary |
... |
additional parameters passed to rio::import and its underlying functions. For example the sheet name for an excel file |
a tibble containing the dictionary
Import a dictionary file with load_dictionary_file() and combine selected
concept ID and definition columns with add_concept_ids().
make_dictionary(path, concept_ids, definitions, ...)make_dictionary(path, concept_ids, definitions, ...)
path |
Path to the dictionary file. |
concept_ids |
Bare concept ID column names, supplied as a single name
or combined with |
definitions |
Bare definition column names, supplied as a single name
or combined with |
... |
Additional arguments passed to |
Column pairs must have equal lengths. Identical ID-definition pairs
and rows with missing concept IDs are removed. Leading numeric value labels
such as 1 = are stripped from definitions. Conflicting definitions issue
a warning, and the first occurrence is retained, using column-pair order
followed by input row order. Missing definitions are retained. See
add_concept_ids() for details.
A tibble with concept_id and definitions columns and one row per
non-missing concept ID. When conflicts occur, the conflict report is stored
in the CID_warning attribute and can be retrieved with cid_warning().
path <- tempfile(fileext = ".csv") utils::write.csv( data.frame( concept_id_1 = c("72841936", "39508271"), definition_1 = c("Age", "Height"), concept_id_2 = c("86173409", "54296813"), definition_2 = c("Weight", "Blood pressure") ), path, row.names = FALSE ) dictionary <- make_dictionary( path, concept_ids = c(concept_id_1, concept_id_2), definitions = c(definition_1, definition_2), colClasses = "character" ) dictionary unlink(path)path <- tempfile(fileext = ".csv") utils::write.csv( data.frame( concept_id_1 = c("72841936", "39508271"), definition_1 = c("Age", "Height"), concept_id_2 = c("86173409", "54296813"), definition_2 = c("Weight", "Blood pressure") ), path, row.names = FALSE ) dictionary <- make_dictionary( path, concept_ids = c(concept_id_1, concept_id_2), definitions = c(definition_1, definition_2), colClasses = "character" ) dictionary unlink(path)