calc_religious_attendance: Calculate Religious Attendance Frequency

View source: R/calc_religious_attendance.R

calc_religious_attendanceR Documentation

Calculate Religious Attendance Frequency

Description

This function creates an ordinal categorical variable indicating the frequency of attending religious meetings or services, based on participant responses.

Usage

calc_religious_attendance(survey_df)

Arguments

survey_df

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

Value

A data frame with two columns: 'person_id' and 'religious_attendance', where 'religious_attendance' indicates how often the participant attends religious meetings or services. Participants without data or who skipped the question will have NA values.

Examples

# Create a sample survey data frame
survey_df <- data.frame(
  person_id = c(1, 2, 3, 4, 5),
  question_concept_id = rep(40192470, 5),
  answer = c("Never", "Once a week", "More than once a week", "Never", "Skip")
)

# Compute religious attendance frequency
religious_attendance_scores <- calc_religious_attendance(survey_df)
head(religious_attendance_scores)


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