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