survival (version 2.9-6)

attrassign: Create new-style "assign" attribute

Description

The "assign" attribute on model matrices describes which columns come from which terms in the model formula. It has two version. R uses the original version, but the newer version is sometimes useful.

Usage

## S3 method for class 'default':
attrassign(object, tt,...)
## S3 method for class 'lm':
attrassign(object,...)

Arguments

object
model matrix or linear model object
tt
terms object
...
ignored

Value

  • A list with names corresponding to the term names and elements that are vectors indicating which columns come from which terms

See Also

terms,model.matrix

Examples

Run this code
data(pbc)
formula<-Surv(time,status)~factor(edtrt)
tt<-terms(formula)
mf<-model.frame(tt,data=pbc)
mm<-model.matrix(tt,mf)
## a few rows of data
mm[1:3,]
## old-style assign attribute
attr(mm,"assign")
## new-style assign attribute
attrassign(mm,tt)

Run the code above in your browser using DataLab