Description Usage Arguments Value Examples
View source: R/sorted_importance.R
Decreasingly sorted frequencies of strings, by default weighted by their length. This function can be used to find the most "important" folder paths in terms of frequency and length.
1 | sorted_importance(x, weighted = TRUE)
|
x |
vector of character strings |
weighted |
if |
named integer vector (of class table) containing the decreasingly
sorted importance values of the elements in x
. The importance of a
string is either its frequency in x
(if weighted is FALSE) or the
product of this frequency and the string length (if weighted is TRUE)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | strings <- c("a", "a", "a", "bc", "bc", "cdefg")
(importance <- kwb.pathdict:::sorted_importance(strings))
# Check that each input element is mentioned in the output
all(unique(strings) %in% names(importance))
# weighted = FALSE just returns the frequencies of strings in x
(importance <- kwb.pathdict:::sorted_importance(strings, weighted = FALSE))
# Check if the sum of frequencies is the number of elements in x
sum(importance) == length(strings)
# You may use the function to assess the "importance" of directory paths
kwb.pathdict:::sorted_importance(dirname(kwb.pathdict:::example_paths()))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.