ft_count | R Documentation |
Reorders the levels of a factor vector based on the count of each level in the data.
ft_count(factor_vec, decreasing = TRUE, inplace = FALSE)
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 |
A factor vector with levels reordered based on their count.
Kai Guo
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.