powered by
data
This function adds an integer column of 1's to data.
1
add_intercept_column(data, name = "(Intercept)")
data with an intercept column.
A data frame or matrix.
The name for the intercept column. Defaults to "(Intercept)", which is the same name that stats::lm() uses.
"(Intercept)"
stats::lm()
If a column named name already exists in data, then data is returned unchanged and a warning is issued.
name
add_intercept_column(mtcars) add_intercept_column(mtcars, "intercept") add_intercept_column(as.matrix(mtcars))
Run the code above in your browser using DataLab