ft_char_freq | R Documentation |
Reorders the levels of a factor vector based on the frequency of characters at specified positions within the data.
ft_char_freq(
factor_vec,
positions,
case = FALSE,
decreasing = TRUE,
inplace = TRUE
)
factor_vec |
A factor vector whose levels are to be reordered. |
positions |
A vector of positive integers specifying the character positions to consider. |
case |
Logical. Should the character comparison be case-sensitive? Default is |
decreasing |
Logical. Should the ordering be decreasing by frequency? Default is |
inplace |
Logical. If |
A factor vector with levels reordered based on the frequency of characters at specified positions.
Kai Guo
# Example factor vector
factor_vec <- factor(c('apple', 'banana', 'apricot', 'cherry', 'banana', 'banana', 'date'))
# Reorder based on characters at positions 1 and 2
ft_char_freq(factor_vec, positions = 1:2)
# Reorder, case-sensitive, decreasing order
ft_char_freq(factor_vec, positions = c(1, 3), case = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.