# Create a sample survey data frame
survey_df <- data.frame(
person_id = c(1, 1, 2, 2, 3, 3, 4, 4),
question_concept_id = c(40192414, 40192492, 40192414, 40192492,
40192414, 40192492, 40192414, 40192492),
answer_concept_id = c(40192514, 40192478, 40192527, 40192422,
40192514, 40192527, 40192422, 40192478)
)
# Compute crime safety scores
crime_safety_scores <- calc_crime_safety(survey_df)
head(crime_safety_scores)
Run the code above in your browser using DataLab