ft_count {fctutils} | R Documentation |
Reorder Factor Levels by Level Count
Description
Reorders the levels of a factor vector based on the count of each level in the data.
Usage
ft_count(factor_vec, decreasing = TRUE, inplace = FALSE)
Arguments
factor_vec |
A factor vector whose levels are to be reordered. |
decreasing |
Logical. Should the ordering be decreasing by count? Default is |
inplace |
Logical. If |
Value
A factor vector with levels reordered based on their count.
Author(s)
Kai Guo
Examples
# Example factor vector
factor_vec <- factor(c('apple', 'banana', 'apple', 'cherry', 'banana', 'banana', 'date'))
# Reorder levels by decreasing count
ft_count(factor_vec)
# Reorder levels by increasing count
ft_count(factor_vec, decreasing = FALSE)
[Package fctutils version 0.0.7 Index]