1% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/as_factor.R
3\name{as_factor}
4\alias{as_factor}
5\alias{as_factor.factor}
6\alias{as_factor.character}
7\alias{as_factor.numeric}
8\alias{as_factor.logical}
9\title{Convert input to a factor}
10\usage{
11as_factor(x, ...)
12
13\method{as_factor}{factor}(x, ...)
14
15\method{as_factor}{character}(x, ...)
16
17\method{as_factor}{numeric}(x, ...)
18
19\method{as_factor}{logical}(x, ...)
20}
21\arguments{
22\item{x}{Object to coerce to a factor.}
23
24\item{...}{Other arguments passed down to method.}
25}
26\description{
27Compared to base R, when \code{x} is a character, this function creates
28levels in the order in which they appear, which will be the same on every
29platform. (Base R sorts in the current locale which can vary from place
30to place.) When \code{x} is numeric, the ordering is based on the numeric
31value and consistent with base R.
32}
33\details{
34This is a generic function.
35}
36\examples{
37# Character object
38x <- c("a", "z", "g")
39as_factor(x)
40as.factor(x)
41
42# Character object containing numbers
43y <- c("1.1", "11", "2.2", "22")
44as_factor(y)
45as.factor(y)
46
47# Numeric object
48z <- as.numeric(y)
49as_factor(z)
50as.factor(z)
51}
52