# \donttest{
# We will use the 'bfi' dataset from the 'psych' package.
# This requires the 'psych' package to be installed.
if (requireNamespace("psych", quietly = TRUE)) {
data(bfi, package = "psych")
# 1. Prepare the data: Select the personality items (first 25 columns)
# and remove rows with missing values for this example.
example_data <- bfi[, 1:25]
example_data <- na.omit(example_data)
# 2. Run the item removal analysis.
# Based on theory, the Big Five model has 5 factors.
results <- itemrest(
data = example_data,
n_factors = 5,
cor_method = "pearson" # Data is not ordinal, so pearson is appropriate
)
# 3. Print the report for optimal strategies (default).
print(results)
# 4. Print the report for all tested strategies.
print(results, report = "all")
}
# }
Run the code above in your browser using DataLab