calc_hcd_count: Calculate Health Care Discrimination Count

View source: R/calc_hcd_count.R

calc_hcd_countR Documentation

Calculate Health Care Discrimination Count

Description

This function creates a numeric score (range 0-7) indicating how many items the participant endorsed for perceived discrimination in health care. Higher scores indicate greater perceived discrimination in health care settings.

Usage

calc_hcd_count(survey_df)

Arguments

survey_df

A data frame containing survey data with at least three columns: 'person_id', 'question_concept_id', and 'answer_concept_id'.

Value

A data frame with two columns: 'person_id' and 'hcd_count', where 'hcd_count' represents the number of health care discrimination items endorsed by the participant. Participants who did not respond to all 7 items will have an NA value.

Examples

# Create a sample survey data frame
survey_df <- data.frame(
  person_id = rep(1:3, each = 7),
  question_concept_id = rep(c(40192383, 40192394, 40192423, 40192425,
                              40192497, 40192503, 40192505), times = 3),
  answer_concept_id = sample(c(40192465, 40192481, 40192429, 40192382, 40192515),
                             21, replace = TRUE)
)

# Compute health care discrimination count
hcd_count_scores <- calc_hcd_count(survey_df)
head(hcd_count_scores)


AOUSDOHtools documentation built on April 3, 2025, 8:11 p.m.