R: Reorder factors levels by first appearance or frequency

fct_inorder {forcats} | R Documentation

## Reorder factors levels by first appearance or frequency

### Description

Reorder factors levels by first appearance or frequency

### Usage

    fct_inorder(f, ordered = NA)

    fct_infreq(f, ordered = NA)

### 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

    f <- factor(c("b", "b", "a", "c", "c", "c"))
    f
    fct_inorder(f)
    fct_infreq(f)

    fct_inorder(f, ordered = TRUE)

[Package forcats version 0.2.0 Index]