Skip to contents

A content-based classifier for the three demographic variables collected by almost every human-subjects study. A column is tagged only when its NAME looks like the demographic AND its VALUES are consistent with it (see .demographic_values_ok), which keeps false positives low: a condition column coded 1/2 is not flagged as gender, and an age column of free text is not treated as usable age data.

Usage

data_check_demographic(col_name, x)

Arguments

col_name

the column's name

x

the column's values

Value

"age", "gender", or "race" when the column matches one of them, else NA_character_.

Details

Complements data_col_type() (which gives a structural type such as continuous/categorical): this adds a semantic label used by data_check (reported in the column table) and data_validate (which reports the demographics a file contains). Detection is name-driven, so a demographic under a cryptic name (e.g. q3) is intentionally not caught here – that is the LLM classifier's job.

Author

Daniel Lakens and Levi Baruch

Examples

data_check_demographic("age", c(23, 45, 31, 29))
#> [1] "age"
data_check_demographic("gender", c("Male", "Female", "Female", "Male"))
#> [1] "gender"
data_check_demographic("condition", c(1, 2, 1, 2))   # NA (name does not match)
#> [1] NA