iterative_ordering | R Documentation |
Turn the chosen columns (factor) of the input data.frame
into ordered factors. For each factor, the order is given by the number of
elements in each level of that factor.
iterative_ordering(df, var_names, i = 1, decreasing = TRUE)
df |
a |
var_names |
character vector containing the names of one or more columns
of |
i |
iteration index (default |
decreasing |
logical value or a vector of them. Each value should be
associated to a |
the input data.frame
with the var_names
variables as
ordered factors.
plotMutualFindings
# From a dataset with some factor columns
mpg <- data.frame(ggplot2::mpg)
# Order the levels of the desired factors based on the cardinality of each
# level.
ordered_mpg <- iterative_ordering(df = mpg,
var_names = c("manufacturer", "model"),
decreasing = c(TRUE, TRUE))
# Now the levels of the factors are ordered in a decreasing way
levels(ordered_mpg$manufacturer)
levels(ordered_mpg$model)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.