h_factor_ref: Convert Character to Factor Following Reference
Description
Convert Character to Factor Following Reference
Usage
h_factor_ref(x, ref, var_name = vname(x))
Value
Factor vector with updated levels.
Arguments
- x
(character or factor)
input.
- ref
(factor)
reference.
- var_name
(string)
variable name of input x.
Details
Use ref to convert x into factor with the same levels.
This is needed even if x and ref are both character because
in model.matrix if x only has one level there could be errors.