EVOLUTION-MANAGER
Edit File: lvls.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: Low-level functions for manipulating levels</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 lvls {forcats}"><tr><td>lvls {forcats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Low-level functions for manipulating levels</h2> <h3>Description</h3> <p><code>lvls_reorder</code> leaves values as they are, but changes the order. <code>lvls_revalue</code> changes the values of existing levels; there must be one new level for each old level. <code>lvls_expand</code> expands the set of levels; the new levels must include the old levels. </p> <h3>Usage</h3> <pre> lvls_reorder(f, idx, ordered = NA) lvls_revalue(f, new_levels) lvls_expand(f, new_levels) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>f</code></td> <td> <p>A factor (or character vector).</p> </td></tr> <tr valign="top"><td><code>idx</code></td> <td> <p>A integer index, with one integer for each existing level.</p> </td></tr> <tr valign="top"><td><code>ordered</code></td> <td> <p>A logical which determines the "ordered" status of the output factor. <code>NA</code> preserves the existing status of the factor.</p> </td></tr> <tr valign="top"><td><code>new_levels</code></td> <td> <p>A character vector of new levels.</p> </td></tr> </table> <h3>Details</h3> <p>These functions are less helpful than the higher-level <code>fct_</code> functions, but are safer than the very low-level manipulation of levels directly, because they are more specific, and hence can more carefully check their arguments. </p> <h3>Examples</h3> <pre> f <- factor(c("a", "b", "c")) lvls_reorder(f, 3:1) lvls_revalue(f, c("apple", "banana", "carrot")) lvls_expand(f, c("a", "b", "c", "d")) </pre> <hr /><div style="text-align: center;">[Package <em>forcats</em> version 0.5.0 <a href="00Index.html">Index</a>]</div> </body></html>