to_factor: To factor

View source: R/metadata.R

to_factorR Documentation

To factor

Description

Convert a labelled vector to a factor, even if it doesn't have the proper class, as long as it has the "labels" attribute. You can have this attribute without, for example, the haven_labelled class, when importing data with rio::import() for example.

Usage

to_factor(x, ...)

Arguments

x

a vector

...

passed to haven::as_factor()

Examples

example("labelled", "haven")
to_factor(x)
to_factor(zap_labelled(x))
to_factor(as_factor(x))
to_factor(1:4)

rubenarslan/codebook documentation built on Nov. 13, 2022, 12:40 p.m.