as.data.frame.Response {irt}R Documentation

Convert a Response-class object into a data.frame.

Description

This function converts Response-class objects to a data.frame object.

Usage

## S3 method for class 'Response'
as.data.frame(
  x,
  row.names = NULL,
  optional = FALSE,
  ...,
  attach_unique_misc = TRUE
)

Arguments

x

An Response-class object

row.names

NULL or a character vector giving the row names for the data frame. Missing values are not allowed.

optional

logical. If TRUE, setting row names and converting column names

...

additional arguments

attach_unique_misc

If TRUE, the elements of the misc slot that have lengths one will be attached to the data frame returned. The default is TRUE.

Value

A data frame of item_ids/responses/scores within each row.

Author(s)

Emre Gonulates

Examples


resp <- response(examinee_id = "Stu12",
                 item_id = c("Item1", "Item2", "Item3", "Item4"),
                 score = c(0, 1, 1, 1),
                 raw_response = c("B", "A", "D", "Right Angle"),
                 order = c(1L, 2L, 3L, 4L),
                 misc = list(item_role = c("F", "O", "O", "O"),
                             lexile_level = c(1, 4, 3, 1),
                             item_type = c("MC", "MC", "MS", "SA"),
                             test_date = as.Date("2021-11-21"),
                             Form = "Test Form 001",
                             theta = 2.2))
as.data.frame(resp)

# Do not include misc fields whose lengths are not equal to the number of
# items
as.data.frame(resp, attach_unique_misc = FALSE)


[Package irt version 0.2.9 Index]