fct_inorder: Reorder factors levels by first appearance or frequency

Description Usage Arguments Examples

View source: R/reorder.R

Description

Reorder factors levels by first appearance or frequency

Usage

1
2
3

Arguments

f

A factor

ordered

A logical which determines the "ordered" status of the output factor. NA preserves the existing status of the factor.

Examples

1
2
3
4
5
6
f <- factor(c("b", "b", "a", "c", "c", "c"))
f
fct_inorder(f)
fct_infreq(f)

fct_inorder(f, ordered = TRUE)

Example output

[1] b b a c c c
Levels: a b c
[1] b b a c c c
Levels: b a c
[1] b b a c c c
Levels: c b a
[1] b b a c c c
Levels: b < a < c

forcats documentation built on May 30, 2017, 6:35 a.m.