EVOLUTION-MANAGER
Edit File: as_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: Convert input to a factor</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 as_factor {forcats}"><tr><td>as_factor {forcats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Convert input to a factor</h2> <h3>Description</h3> <p>Compared to base R, when <code>x</code> is a character, this function creates levels in the order in which they appear, which will be the same on every platform. (Base R sorts in the current locale which can vary from place to place.) When <code>x</code> is numeric, the ordering is based on the numeric value and consistent with base R. </p> <h3>Usage</h3> <pre> as_factor(x, ...) ## S3 method for class 'factor' as_factor(x, ...) ## S3 method for class 'character' as_factor(x, ...) ## S3 method for class 'numeric' as_factor(x, ...) ## S3 method for class 'logical' as_factor(x, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>Object to coerce to a factor.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Other arguments passed down to method.</p> </td></tr> </table> <h3>Details</h3> <p>This is a generic function. </p> <h3>Examples</h3> <pre> # Character object x <- c("a", "z", "g") as_factor(x) as.factor(x) # Character object containing numbers y <- c("1.1", "11", "2.2", "22") as_factor(y) as.factor(y) # Numeric object z <- as.numeric(y) as_factor(z) as.factor(z) </pre> <hr /><div style="text-align: center;">[Package <em>forcats</em> version 0.5.0 <a href="00Index.html">Index</a>]</div> </body></html>