Skip to content

Commit f0fa18e

Browse files
committed
better accessor
1 parent f0e3d1a commit f0fa18e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

R/extract.item.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
#' @param x mirt model of class \code{'SingleGroupClass'}, \code{'MultipleGroupClass'}, or
77
#' \code{'MixtureClass'}
88
#' @param item a number or character signifying which item to extract
9-
#' @param group a number signifying which group the item should be extracted from (applies to
10-
#' \code{'MultipleGroupClass'} and \code{'MixtureClass'} only)
9+
#' @param group which group the item should be extracted from (applies to
10+
#' \code{'MultipleGroupClass'} and \code{'MixtureClass'} only). Can be a numeric
11+
#' value or the name of the group to be extracted
1112
#' @param drop.zeros logical; drop slope values that are numerically close to zero to reduce
1213
#' dimensionality? Useful in objects returned from \code{\link{bfactor}} or other confirmatory
1314
#' models that contain several zero slopes
@@ -35,6 +36,10 @@ extract.item <- function(x, item, group = NULL, drop.zeros = FALSE){
3536
if(!is.numeric(item)) item <- ind[inames == item]
3637
if(is(x, 'MultipleGroupClass') || is(x, 'MixtureClass')){
3738
if(is.null(group)) stop('Which group are you trying to extract from?', call.=FALSE)
39+
if(is.character(group)){
40+
grp <- extract.mirt(x, 'groupNames')
41+
group <- which(group == grp)
42+
}
3843
ret <- extract.mirt(extract.mirt(x, 'pars')[[group]], 'pars')[[item]]
3944
} else {
4045
ret <- extract.mirt(x, 'pars')[[item]]

man/extract.item.Rd

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)