EVOLUTION-MANAGER
Edit File: parse_factor.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Parse factors</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for parse_factor {readr}"><tr><td>parse_factor {readr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Parse factors</h2> <h3>Description</h3> <p><code>parse_factor</code> is similar to <code><a href="../../base/html/factor.html">factor()</a></code>, but will generate warnings if elements of <code>x</code> are not found in <code>levels</code>. </p> <h3>Usage</h3> <pre> parse_factor(x, levels = NULL, ordered = FALSE, na = c("", "NA"), locale = default_locale(), include_na = TRUE, trim_ws = TRUE) col_factor(levels = NULL, ordered = FALSE, include_na = FALSE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>Character vector of values to parse.</p> </td></tr> <tr valign="top"><td><code>levels</code></td> <td> <p>Character vector providing set of allowed levels. if <code>NULL</code>, will generate levels based on the unique values of <code>x</code>, ordered by order of appearance in <code>x</code>.</p> </td></tr> <tr valign="top"><td><code>ordered</code></td> <td> <p>Is it an ordered factor?</p> </td></tr> <tr valign="top"><td><code>na</code></td> <td> <p>Character vector of strings to interpret as missing values. Set this option to <code>character()</code> to indicate no missing values.</p> </td></tr> <tr valign="top"><td><code>locale</code></td> <td> <p>The locale controls defaults that vary from place to place. The default locale is US-centric (like R), but you can use <code><a href="locale.html">locale()</a></code> to create your own locale that controls things like the default time zone, encoding, decimal mark, big mark, and day/month names.</p> </td></tr> <tr valign="top"><td><code>include_na</code></td> <td> <p>If <code>NA</code> are present, include as an explicit factor to level?</p> </td></tr> <tr valign="top"><td><code>trim_ws</code></td> <td> <p>Should leading and trailing whitespace be trimmed from each field before parsing it?</p> </td></tr> </table> <h3>See Also</h3> <p>Other parsers: <code><a href="col_skip.html">col_skip</a></code>, <code><a href="spec.html">cols_condense</a></code>, <code><a href="cols.html">cols</a></code>, <code><a href="parse_datetime.html">parse_datetime</a></code>, <code><a href="parse_guess.html">parse_guess</a></code>, <code><a href="parse_atomic.html">parse_logical</a></code>, <code><a href="parse_number.html">parse_number</a></code>, <code><a href="parse_vector.html">parse_vector</a></code> </p> <h3>Examples</h3> <pre> parse_factor(c("a", "b"), letters) x <- c("cat", "dog", "caw") levels <- c("cat", "dog", "cow") # Base R factor() silently converts unknown levels to NA x1 <- factor(x, levels) # parse_factor generates a warning & problems x2 <- parse_factor(x, levels) # Using an argument of `NULL` will generate levels based on values of `x` x2 <- parse_factor(x, levels = NULL) </pre> <hr /><div style="text-align: center;">[Package <em>readr</em> version 1.3.1 <a href="00Index.html">Index</a>]</div> </body></html>