R/addIndicators.R

Defines functions addIndicators

Documented in addIndicators

addIndicators <- function(data, formula, drop.intercept = TRUE) {
  mm <- stats::model.matrix(formula,data)
  if (drop.intercept && any(intercept <- "(Intercept)" %in% names(mm)))
      mm <- mm[, !intercept, drop = FALSE]
  for (name in colnames(mm))
      data[[name]] <- mm[, name]
  data
}

Try the biostat3 package in your browser

Any scripts or data that you put into this service are public.

biostat3 documentation built on Nov. 2, 2023, 6:04 p.m.