collapse {lordif} | R Documentation |
collapses response categories if cell frequencies are less than the specified minimum threshold (i.e., minCell) and returns a vector of recoded values.
collapse(resp, group, minCell)
resp |
a vector of item responses |
group |
a vector of group designations |
minCell |
a minimum cell frequency |
Collapses item response categories in resp if the two-way contingency table (resp x group) has cell frequencies less than the minimum cell count threshold specified by minCell.
a numeric vector of the same length as resp with collapsed/recoded values.
Item responses are expected to start from 1 not 0 (e.g., 1, 2, 3, 4, 5 and not 0, 1, 2, 3, 4). There must be at least two unique categories after collapsing/recoding.
Seung W. Choi <s-choi@northwestern.edu>
r1 <- c(1,1,2,1,1,2,2,1,2,2,1,2,2,1,1,2,1,2,2,3,3,1,2,3) gr <- c(0,0,0,1,1,0,1,1,0,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1) collapse(r1,gr,2) #minCell=2 ## returns c(1,1,2,1,1,2,2,1,2,2,1,2,2,1,1,2,1,2,2,2,2,1,2,2) ## response categories 2 and 3 are collapsed