View source: R/response_set-class-methods.R
response_set | R Documentation |
Response_set-class
objectThis function creates a Response_set-class
object
from various types of data sets. Currently following scenarios are
supported:
response_set( x, data_format = "wide", ip = NULL, examinee_id_var = NULL, testlet_id_var = NULL, item_id_var = NULL, score_var = NULL, raw_response_var = NULL, order_var = NULL, response_time_var = NULL, misc_var = NULL, misc_unique_var = NULL, misc = NULL, fill_na_score = NULL )
x |
A |
data_format |
A string value representing the format of the data
|
ip |
Optionally an |
examinee_id_var |
A string for the column name that holds examinee
ids, if |
testlet_id_var |
A string for the column name that holds testlet
ids, if |
item_id_var |
A string for the column name that holds item
ids, if |
score_var |
A string for the column name that holds examinee
scores, if |
raw_response_var |
A string for the column name that holds raw
responses of the examinees, if |
order_var |
A string for the column name that holds the administration
order of items, if |
response_time_var |
A string for the column name that holds response
time information of the items, if |
misc_var |
A string for the column names that are holding the
miscellaneous information of the items. Available only when |
misc_unique_var |
A string for the column names that are holding the
miscellaneous information of the items. Different than |
misc |
A list of miscellaneous variables that needs to be added to
the |
fill_na_score |
If some examinees do not answer all items, the value
Currently, this feature only works when |
A Response_set-class
object.
Emre Gonulates
##### Wide format data ##### ## Example 1 x_wide <- matrix(sample(0:1, 35, TRUE), nrow = 7, ncol = 5) response_set(x_wide) ## Example 2 ip <- generate_ip(n = 6) # simulate responses for 10 examinees resp_matrix <- sim_resp(ip = ip, theta = rnorm(10), prop_missing = .2, output = "matrix") # convert it to tibble resp_wide <- as.data.frame(resp_matrix) resp_wide$stu_id <- rownames(resp_matrix) # Create a Response_set object: resp_set <- response_set(resp_wide, data_format = "wide", ip = ip, examinee_id_var = "stu_id") # Retrieve examinee ids: resp_set$examinee_id # Fourth examinee: resp_set[[4]] # Scores of 6th examinee resp_set[[6]]$score ##### Long format data ##### x_long <- data.frame(examinee_id = c("stu1", "stu1", "stu1", "stu2", "stu2"), item_id = c("i1", "i2", "i4", "i1", "i2"), scr = c(0, 1, 0, 1, 0), rwscore = c("A", "D", "B", "C", "D"), resptime = c(33, 55, 22, 66, 31), # These will be passed to misc item_type = c("MC", "MC", "MS", "SA", "MC"), lexile_level = c(1, 4, 3, 2, 1), word_count = c(123, 442, 552, 342, 666), ability = c(1.1, 1.1, 1.1, -.2, -.2), grade = c("7", "7", "7", "11", "11") ) resp_set <- response_set(x = x_long, data_format = "long", examinee_id_var = "examinee_id", item_id_var = "item_id", score_var = "scr", raw_response_var = "rwscore", response_time_var ="resptime", misc_var = c("item_type", "lexile_level"), misc_unique_var = c("ability", "grade") ) resp_set[[1]] # Response of the first examinee resp_set$item_type # extract item_type of each examinee resp_set$grade # extract grade of each examinee # Also, additional examinee level miscellaneous information can be added: resp_set$gender <- c("M", "F") resp_set[[2]]$gender # access second examinee's gender. resp_set$gender # Fill missing values with 0. response_set(x = x_long, data_format = "long", examinee_id_var = "examinee_id", item_id_var = "item_id", score_var = "scr", raw_response_var = "rwscore", response_time_var ="resptime", misc_var = c("item_type", "lexile_level"), fill_na_score = 0 )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.