inst/doc/ItemRest_Demonstration.R

## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup--------------------------------------------------------------------
library(ItemRest)

## ----data_prep----------------------------------------------------------------
# Ensure the 'psych' package is available
if (requireNamespace("psych", quietly = TRUE)) {
  data(bfi, package = "psych")
  
  # Select the personality items (first 25 columns)
  analysis_data <- bfi[, 1:25]
  
  # Omit rows with missing values for this example
  analysis_data <- na.omit(analysis_data)
  
  # View the first few rows of the prepared data
  head(analysis_data)
}

## ----run_analysis-------------------------------------------------------------
# Run the analysis
if (exists("analysis_data")) {
  results <- itemrest(
  data = analysis_data,
  n_factors = 5,
  min_loading = 0.30,
  loading_diff = 0.10
)
}

## ----print_optimal------------------------------------------------------------
if (exists("results")) {
  # Print the default optimal report
  print(results, report = "optimal")
}

## ----print_all----------------------------------------------------------------
if (exists("results")) {
  # Print the report for all tested strategies
  print(results, report = "all")
}

Try the ItemRest package in your browser

Any scripts or data that you put into this service are public.

ItemRest documentation built on April 13, 2026, 5:07 p.m.