reorder_labels: Reorder categories according to frequency

Description Usage Arguments Details Value

View source: R/misc.R

Description

Takes a integer, character, or factor vector and reorder the labels according to the frequency with which they appear.

Usage

1
reorder_labels(x, decreasing = TRUE)

Arguments

x

integer or character vector, or factor variable

decreasing

boolean; if TRUE, orders in decreasing order, otherwise in increasing order

Details

It is assumed that the labels of x have an inherent ordering. reorder_labels reorders the labels such that the first label is assigned to the category with the highest frequency, the second label to the second most frequent category, and so on.

Value

returns x with labels ordered according to frequencies


baruuum/btoolbox documentation built on Aug. 17, 2020, 1:29 a.m.