Converts x
to a factor and keeps its attributes. Warns appropriately such that the user
can decide whether they prefer converting to factor manually (e.g. for full control of
factor levels).
as_factor_keep_attributes(
x,
x_name = deparse(substitute(x)),
na_level = "",
verbose = TRUE
)
A factor
with same attributes (except class) as x
. Does not modify x
if already a factor
.
(vector
)
object to convert.
(string
)
name of x
.
(string
)
the explicit missing level which should be used when converting a character vector.
(flag
)
defaults to TRUE
. It prints out warnings and messages.