mt <- attr(x = mf, which = "terms") x <- model.matrix(object = mt, data = mf, contrasts.arg = contrasts)