irtc_excel: Export Three Excel Result Workbooks

View source: R/irtc_excel.R

irtc_excelR Documentation

Export Three Excel Result Workbooks

Description

One call writes three separate .xlsx files (requires the optional openxlsx package):

  1. <prefix>_item_quality.xlsx - a plain-language item quality table (score rate, difficulty label, discrimination, fit, colour-coded overall rating, reasons and advice) plus a notes sheet explaining every column, for judging item quality without statistical training.

  2. <prefix>_item_parameters.xlsx - the IRT difficulty / discrimination table with a frozen column schema (schema_version, analysis_id, model, item_id, n_obs, p_value, slope_a, difficulty_b, se_b, tau_k), designed for cross-year anchor-item linking: files from different administrations can be merged directly on item_id.

  3. <prefix>_person_ability.xlsx - a flat person ability table (ID, number answered, raw score, EAP, standard error, percentile, T score) whose rows stay in input order so it can be pasted next to a master sample sheet.

Usage

irtc_excel(mod, dir = ".", prefix = "IRTC", lang = irtc_lang(),
    resp = NULL, overwrite = FALSE, verbose = TRUE)

irtc_param_table(mod, resp = NULL)

irtc_person_table(mod, lang = irtc_lang())

Arguments

mod

A fitted irtc model object.

dir

Output directory (created if necessary).

prefix

File name prefix.

lang

Language of headers and notes, "zh" or "en". The linking schema of file 2 is language-independent.

resp

The response data; only needed when the model object does not store it (streaming engine).

overwrite

Logical: overwrite existing files? Otherwise an error of class irtc_error_export (code E501) is raised.

verbose

Logical: print a completion message?

Value

irtc_excel invisibly returns a named character vector with the three file paths (quality, parameters, ability). irtc_param_table and irtc_person_table return the underlying data frames and work without openxlsx.

See Also

irtc, irtc_report, irtc_results

Examples

set.seed(1)
theta <- rnorm(150)
resp <- as.data.frame(sapply(seq(-1, 1, length.out = 5), function(b) {
    as.numeric(runif(150) < plogis(theta - b))
}))
mod <- irtc(resp, model = "1PL", verbose = FALSE)

## data frames behind the workbooks (no extra packages needed)
irtc_param_table(mod)
head(irtc_person_table(mod, lang = "en"))

if (requireNamespace("openxlsx", quietly = TRUE)) {
    out <- irtc_excel(mod, dir = tempdir(), overwrite = TRUE,
        verbose = FALSE)
    basename(out)
}

IRTC documentation built on July 24, 2026, 5:07 p.m.