Patrick O'Reilly <patrick.a.oreilly <at> gmail.com> writes: > > Hi, > > As far as I am aware, the model.matrix function does not return > perfect metadata on what each column of the model matrix "means". > > The columns are named (e.g. age:genderM), but encoding the metadata as > strings can result in ambiguity. For example, the dummy variables > created when the factors var0 = 0 and var = 00 both are named var00. > Additionally, if a level of a factor variable contains a colon, this > could be confused for an interaction. > > While a human can generally work out the meaning of each column > somewhat manually, I am interested in achieving this programmatically. >
Why don't you just retain the terms.object? i.e my.terms <- terms( my.formula, data=my.data.frame ) my.model.matrix <- model.matrix( my.terms, data= my.data.frame ) attributes(my.terms) See ?terms, ?terms.object, ?model.frame (which contains a terms.object) HTH, Chuck ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel