Learn R Programming

irt (version 0.1.1)

as.data.frame.Itempool: Convert an Itempool-class object into a data.frame.

Description

This function converts Itempool-class objects to a data.frame object. All of the items in the item pool should be the same model. If the items belongs to different psychometric models, then, a list of items will be returned instead.

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

This function converts Testlet-class objects to a data.frame object. If testlet has an ID, an additional column will be created for the testlet ID.

Usage

# S3 method for Itempool
as.data.frame(x, row.names = NULL, optional = FALSE, ..., include_se = TRUE)

# S3 method for Item as.data.frame(x, row.names = NULL, optional = FALSE, ..., include_se = TRUE)

# S3 method for Testlet as.data.frame(x, row.names = NULL, optional = FALSE, ..., include_se = TRUE)

Arguments

x

An Testlet-class object

row.names

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

optional

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

...

additional arguments

include_se

If TRUE, and items have se_parameters, those will be included in the data frame.

Value

A data frame of items within each row. If all items cannot be coerced to a data.frame, an list of items will be returned and a warning will be raised.

A data frame representation of the item.

A data frame representation of the item.

Examples

Run this code
# NOT RUN {
ip1 <- generate_ip()
as.data.frame(ip1)

ip2 <- generate_ip(n = 10, model = "GRM",
                   content = sample(c("G", "A"), 10, TRUE),
                   id = paste0("grm-i-", 1:10))
as.data.frame(ip2)

t1 <- generate_testlet(n = 3, item_id_preamble = "t1")
t2 <- generate_testlet(n = 2, item_id_preamble = "t2")
ip3 <- c(ip1, t1, t2)
as.data.frame(ip3)

ip4 <- c(ip2, ip3)
as.data.frame(ip4)


item1 <- item(a = 1.12, b = -2.1, c = 0.28)
item2 <- item(a = 2, b = 3.2, c = 0.21)

ip1 <- c(item1, item2)
as.data.frame(ip1)
item1 <- generate_item()
as.data.frame(item1)
testlet1 <- generate_testlet()
as.data.frame(testlet1)
testlet2 <- generate_testlet(id = "T1")
as.data.frame(testlet2)
# }

Run the code above in your browser using DataLab