calc_housing_quality {AOUSDOHtools} | R Documentation |
Calculate Housing Quality Needs
Description
This function creates a binary categorical variable indicating whether a participant endorses having any housing-related problems (housing need). A value of TRUE indicates the participant selected at least one housing problem, while FALSE indicates no problems were reported.
Usage
calc_housing_quality(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 'housing_quality', where 'housing_quality' is a TRUE or FALSE indicator for each participant. TRUE indicates the participant selected at least one housing problem, and FALSE indicates no housing problems. Participants without data will have NA values.
Examples
# Create a sample survey data frame
survey_df <- data.frame(
person_id = c(1, 2, 3, 4, 5, 6, 7),
question_concept_id = rep(40192402, 7),
answer_concept_id = c(40192392, 40192479, 40192444, 40192460,
40192434, 40192468, 40192393)
)
# Compute housing quality needs
housing_quality_scores <- calc_housing_quality(survey_df)
head(housing_quality_scores)
[Package AOUSDOHtools version 1.0.4 Index]