take the factor levels in training data and copy them over to testing data. This is an important pre-processing step for data splits that may have different factor levels in training and testing sets.
cat_transfer(to, from)
to | the data that factor levels are transferred to |
---|---|
from | the data that factor levels are transferred from |
to
and from
must have the same factor columns. For example,
if to
has a factor named A
and from
does not have a factor
of the same name, the function will stop and tell you which
factor variables are missing.