## S3 method for class 'itemresp'
subset(x, items = NULL, subjects = NULL, ...)
Arguments
x
an object of class “itemresp”.
items
character, integer, or logical for subsetting the items.
subjects
character, integer, or logical for subsetting the subjects.
…
currently not used.
Details
The subset method selects subsets of items and/or subjects in item response data. Alternatively, the [ method can be used with the row index corresponding to subjects and the column index corresponding to items.
The c method can be used to combine item response data from different subjects for the same items
The merge method can be used to combine item response data from the same subjects for different items.
See Also
itemresp
Examples
library("psychotools")## binary responses to three items, coded as matrixx<-cbind(c(1, 0, 1, 0), c(1, 0, 0, 0), c(0, 1, 1, 1))xi<-itemresp(x)## subsetting/indexingxi[2]
## combine two itemresp vectors for different subjects but the same itemsxi12<-xi[1:2]xi34<-xi[3:4]c(xi12, xi34)
[1] {1,1,0} {0,0,1} {1,0,1} {0,0,1}
## combine two itemresp vectors for the same subjects but different items## polytomous responses in a data framed<-data.frame(q1 =c(-2, 1, -1, 0), q2 =factor(c(1, 3, 1, 3), levels =1:3, labels =c("disagree", "neutral", "agree")))di<-itemresp(d)merge(xi, di)
## if subjects have names/IDs, these are used for mergingnames(xi)<-c("John", "Joan", "Jen", "Jim")names(di)<-c("Joan", "Jen", "Jim", "Jo")merge(xi, di)
Joan Jen Jim
{0,0,1,-2,dsgr} {1,0,1,1,agre} {0,0,1,-1,dsgr}