Skip to content

Coercion functions for creating factors from other existing objects.

Usage

as.factor(x, ...)

as.ordered(x, ...)

Arguments

x

A vector of data.

...

Other arguments passed on to methods.

Value

For as.factor(), a factor. For as.ordered(), an ordered factor.

Details

These functions override non-generic factor coercion functions provided in base so that packages can provide methods for different data types. The default methods call the base versions.

Methods

as.factor()

No methods found in currently loaded packages.

as.ordered()

No methods found in currently loaded packages.

Examples

as.factor(letters[1:5])
#> [1] a b c d e
#> Levels: a b c d e
as.ordered(letters[1:5])
#> [1] a b c d e
#> Levels: a < b < c < d < e