Order-preserving factors

Share:

Description

The function ofactor is a convenience wrapper for factor that orders the levels as they appear in the data if the levels argument is not specified.

Usage

1

Arguments

x

A vector of data, usually taking a small number of distinct values.

...

Other arguments passed on to factor.

Value

A factor. See factor for details.

Examples

1
2
3
ofactor(3:1)
ofactor(9:12, exclude=11)
identical(ofactor(3:1, levels=1:3), factor(3:1))