# Generate sample dichotomous data
set.seed(123)
my_data <- as.data.frame(
matrix(rbinom(200 * 10, 1, 0.6), nrow = 200)
)
# Calculate weighted sum scores
total_scores <- weighted_sum_score(my_data, threshold = 1)
# View the first few scores
cat("--- Weighted Total Scores (Head) ---\n")
print(head(total_scores))
# Compare with simple unweighted scores
unweighted_scores <- rowSums(my_data)
cat("\n--- Unweighted Total Scores (Head) ---\n")
print(head(unweighted_scores))
Run the code above in your browser using DataLab