as_factor: Convert input to a factor.

Description Usage Arguments Details Examples

View source: R/as_factor.R

Description

Compared to base R, 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.)

Usage

1
2
3
4
5
6
7
as_factor(x, ...)

## S3 method for class 'factor'
as_factor(x, ...)

## S3 method for class 'character'
as_factor(x, ...)

Arguments

x

Object to coerce to a factor.

...

Other arguments passed down to method.

Details

This is a generic function.

Examples

1
2
3
x <- c("a", "z", "g")
as_factor(x)
as.factor(x)

tidyverse/forcats documentation built on Jan. 11, 2019, 11:10 a.m.