Swaps the responses behind a lab made with new_lab() for another
dataset, for example next year's class or your own test. The lab's text,
answer checks and questions are computed from the data, so nothing else
needs to change. Settings you leave out (group, data_title, story)
are kept from the current data, except that items and key are always
worked out again. The item_info and scores of the AI sections are kept
unless you give new ones. Run check_material() afterwards.
Usage
swap_lab_data(
lab,
data,
items = NULL,
group = NULL,
key = NULL,
item_info = NULL,
scores = NULL,
data_title = NULL,
story = NULL
)Arguments
- lab
the lab folder.
- data
the responses: A data frame or matrix, or the path of a file (
.csv,.tsv,.txt,.xlsx,.xls,.sav,.dta,.sas7bdator.rds). Items must be scored 0/1 or in ordered integer categories, unless you give akey. A frequency table (one row per response pattern with afreqorcountcolumn, such as mirt::LSAT7) is expanded to one row per person.- items
the item columns, by name or position. By default, every column whose values are whole numbers from 0 to 9 (other than
groupand ID-like columns), or the names of a namedkey.- group
optional grouping variable with two values, for the DIF section: A column name of
data, or a vector with one value per row.- key
optional answer key for unscored multiple-choice responses, one value per item; the items are scored with
mirt::key2binary().- item_info
optional data frame (or the path of a data file) with one row per item, for the AI sections. It needs a column
item(orid) with the item names used indata. Astemcolumn (and, for multiple-choice items, option columnsAtoEand akeycolumn with the letter of the keyed option) enables the"item-features"section; afamilycolumn naming each item's item model or family enables the"aig"section.- scores
optional data frame (or the path of a data file) of machine scores of constructed responses, for the
"ai-scoring"section: One row per scored response, with columnsmachineandhuman1(the human score,NAwhere no person read the response) and, optionally,human2(a second reading),group(for fairness checks),itemandperiod(an administration or engine version, for drift checks). Rename your columns to these names first.- data_title
a short name for the data used in the lab's text, for example
"the Grade 8 science test".- story
a paragraph that sets the scene, shown at the start of the lab.
Details
If the lab has a DIF section and the new data have no group, the DIF
section will fail; remove it with remove_lab_section().
Examples
course <- file.path(tempdir(), "swap-demo")
lab <- new_lab("demo", data = expand.table(LSAT7), course = course,
sections = c("intro", "classical"))
swap_lab_data(lab, data = expand.table(LSAT6), data_title = "the LSAT section 6 items")
lab_data(file.path(lab, "data"))$info$data_title
#> [1] "the LSAT section 6 items"