as_factor

0th

Percentile

Convert input to a factor.

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
as_factor(x, ...)

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

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

# S3 method for numeric as_factor(x, ...)

Arguments
x

Object to coerce to a factor.

...

Other arguments passed down to method.

Details

This is a generic function.

Aliases
  • as_factor
  • as_factor.factor
  • as_factor.character
  • as_factor.numeric
Examples
# NOT RUN {
x <- c("a", "z", "g")
as_factor(x)
as.factor(x)
y <- c("1.1", "11", "2.2", "22")
as_factor(y)
as.factor(y)
# }
Documentation reproduced from package forcats, version 0.4.0, License: GPL-3

Community examples

Looks like there are no examples yet.