readr (version 1.0.0)

parse_factor: Parse a character vector into a factor

Description

Parse a character vector into a factor

Usage

parse_factor(x, levels, ordered = FALSE, na = c("", "NA"), locale = default_locale())
col_factor(levels, ordered = FALSE)

Arguments

x
Character vector of values to parse.
levels
Character vector providing set of allowed levels.
ordered
Is it an ordered factor?
na
Character vector of strings to use for missing values. Set this option to character() to indicate no missing values.
locale
The locale controls defaults that vary from place to place. The default locale is US-centric (like R), but you can use locale to create your own locale that controls things like the default time zone, encoding, decimal mark, big mark, and day/month names.

See Also

Other parser: parse_atomic, parse_datetime, parse_guess, parse_number

Examples

Run this code
parse_factor(c("a", "b"), letters)

Run the code above in your browser using DataCamp Workspace