ft_substr_freq | R Documentation |
Reorders the levels of a factor vector based on the frequency of substrings extracted from the data.
ft_substr_freq(
factor_vec,
start_pos = NULL,
end_pos = NULL,
case = FALSE,
decreasing = TRUE,
inplace = TRUE
)
factor_vec |
A factor vector whose levels are to be reordered. |
start_pos |
Positive integer. The starting position of the substring. If |
end_pos |
Positive integer. The ending position of the substring. If |
case |
Logical. Should the substring 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 substrings.
Kai Guo
# Example factor vector with multi-byte characters
factor_vec <- factor(c('apple', 'banana', 'apricot', 'cherry', 'banana', 'banana', 'date'))
# Reorder from position 2 to end
ft_substr_freq(factor_vec, start_pos = 2)
factor_vec <- factor(c('apple', 'banana', 'apricot', 'cherry', 'banana', 'banana', 'date'))
ft_substr_freq(factor_vec, start_pos = 2, end_pos=3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.