Learn R Programming

irt (version 0.2.9)

as.data.frame.Response: 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 Response
as.data.frame(
  x,
  row.names = NULL,
  optional = FALSE,
  ...,
  attach_unique_misc = TRUE
)

Value

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

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.

Author

Emre Gonulates

Examples

Run this code

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)

Run the code above in your browser using DataLab