ynbind: Combine Variables in a Matrix

View source: R/ynbind.s

ynbindR Documentation

Combine Variables in a Matrix


ynbind column binds a series of related yes/no variables, allowing for a final argument label used to label the panel created for the group. labels for individual variables are collected into a vector attribute "labels" for the result; original variable names are used in place of labels for those variables without labels. A positive response is taken to be y, yes, present (ignoring case) or a logical TRUE value. By default, the columns are sorted be ascending order or the overall proportion of positives. A subsetting method is provided for objects of class "ynbind".

pBlock creates a matrix similarly labeled, from a general set of variables (without special handling of binaries), and sets to NA any observation not in subset so that when that block of variables is analyzed it will be only for that subset.


ynbind(..., label = deparse(substitute(...)),
       asna = c("unknown", "unspecified"), sort = TRUE)

pBlock(..., subset=NULL, label = deparse(substitute(...)))



a series of vectors


a label for the group, to be attached to the resulting matrix as a "label" attribute, used by summaryP.


a vector of character strings specifying levels that are to be treated the same as NA if present


set to FALSE to not sort the columns by their proportions


subset criteria - either a vector of logicals or subscripts


a matrix of class "ynbind" or "pBlock" with "label" and "labels" attributes. For "pBlock", factor input vectors will have values converted to character.


Frank Harrell

See Also



x1 <- c('yEs', 'no', 'UNKNOWN', NA)
x2 <- c('y', 'n', 'no', 'present')
label(x2) <- 'X2'
X <- ynbind(x1, x2, label='x1-2')

pBlock(x1, x2, subset=2:3, label='x1-2')

harrelfe/Hmisc documentation built on May 19, 2024, 4:13 a.m.