Learn R Programming

ribiosUtils (version 1.7.7)

ofactor: Ordered factor

Description

Build a factor using the order of input character strings

Usage

ofactor(x, ...)

Value

Factor with levels in the same order of the input strings.

Arguments

x

A vector of character strings

...

Other parameters passed to factor

Author

Jitao David Zhang <jitao_david.zhang@roche.com>

See Also

factor

Examples

Run this code

testStrings <- c("A", "C", "B", "B", "C")
(testFac <- factor(testStrings))
(testOfac <- ofactor(testStrings))

stopifnot(identical(levels(testOfac), c("A", "C", "B")))

Run the code above in your browser using DataLab