Summarize person type assignment
summarize_person_types.RdProvides 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.
Arguments
- persons
data.table A table of person-level records containing at least:
person_idageemploymentschool_typestudent.
- person_type_dt
data.table A table produced by
calc_person_type()withperson_idandperson_type.- value_labels
data.table A lookup table of value labels with columns
variable,value, andlabel. Used to attach human-readable labels in the summary output.
Value
list A list with two elements:
summary: data.table with counts (N) byperson_type,age_label,employment_label,school_type_label, andstudent_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
} # }