Create a U-dummy matrix for one variable
getUDummyMatForOneVec(
x_vec,
levels = NULL,
drop_last = TRUE,
only_info = FALSE
)
A list with the following fields:
levels
: Same as input.
drop_last
: Same as input.
dummy_mat
: The created U-dummy matrix (only if only_info=FALSE
).
A vector representing original variable.
The class of x_vec
should be one of integer
, character
, or factor
.
A character vector representing values of x_vec
used to create U-dummies.
If NULL
, all the unique values of x_vec
are used to create dummies.
If TRUE
, the last column of the resulting matrix is dropped to avoid multicollinearity.
If TRUE
, only information fields of returned values are filled and no dummy matrix is returned.
Kenji Kondo