characterize(x,...)factorize(x,...)## Default S3 method:characterize(x,...)## S3 method for class 'data.frame'characterize(x,...)## Default S3 method:factorize(x, coerce_character =FALSE,...)## S3 method for class 'data.frame'factorize(x,...)
Arguments
x: A vector or data frame.
...: additional arguments passed to methods
coerce_character: A logical indicating whether to additionally coerce character columns to factor (in factorize). Default FALSE.
Returns
a character vector (for characterize) or factor vector (for factorize)
Details
characterize converts a vector with a labels attribute of named levels into a character vector. factorize does the same but to factors. This can be useful at two stages of a data workflow: (1) importing labelled data from metadata-rich file formats (e.g., Stata or SPSS), and (2) exporting such data to plain text files (e.g., CSV) in a way that preserves information.