Skip to contents

Provides a QA/QC summary of how person types were assigned. Cross-tabulates underlying attributes (age, employment, school_type, student) against the final person_type. Flags any employment, school_type, or student codes that were not mapped into a category, so analysts can identify unexpected or new questionnaire values.

Usage

summarize_person_types(persons, person_type_dt, value_labels)

Arguments

persons

data.table A table of person-level records containing at least:

  • person_id

  • age

  • employment

  • school_type

  • student.

person_type_dt

data.table A table produced by calc_person_type() with person_id and person_type.

value_labels

data.table A lookup table of value labels with columns variable, value, and label. Used to attach human-readable labels in the summary output.

Value

list A list with two elements:

  • summary: data.table with counts (N) by person_type, age_label, employment_label, school_type_label, and student_label.

  • unmapped: data.table of codes in employment, school_type, or student that were not matched into a person type.

Examples

if (FALSE) { # \dontrun{
persons <- fetch_hts_table("person", settings)
value_labels <- fetch_hts_table("value_labels", settings)
person_type_dt <- calc_person_type(persons, value_labels)
qa_results <- summarize_person_types(persons, person_type_dt, value_labels)
head(qa_results$summary)
qa_results$unmapped
} # }