## Example 1: Dichotomous Data (as in the original study)
set.seed(123)
n_students_dich <- 200
n_items_dich <- 10
dich_data <- as.data.frame(
matrix(
rbinom(n_students_dich * n_items_dich, 1, 0.6),
nrow = n_students_dich
)
)
cat("--- Original Dichotomous Data (Head) ---\n")
print(head(dich_data))
weighted_dich <- item_weighting(dich_data)
cat("\n--- Weighted Dichotomous Data (Head) ---\n")
print(head(weighted_dich))
## Example 2: 5-Point Likert-Type Data
# Note: The function was designed for 0-1 data. With Likert data,
# the person's average score will likely be > 1, causing the weighting
# condition to be met for almost all responses.
set.seed(456)
n_students_likert <- 150
n_items_likert <- 15
likert_data <- as.data.frame(
matrix(
sample(1:5, size = n_students_likert * n_items_likert, replace = TRUE),
nrow = n_students_likert
)
)
cat("\n--- Original 5-Point Likert Data (Head) ---\n")
print(head(likert_data))
weighted_likert <- item_weighting(likert_data)
cat("\n--- Weighted 5-Point Likert Data (Head) ---\n")
print(head(weighted_likert))
Run the code above in your browser using DataLab