Assign each element of a numeric vector to a group. Grouping is based on ranks:
numeric values are sorted and then split in 2 or more groups. Values may be sorted
in an increasing or decreasing fashion. The vector is returned in the original order.
Labels may be assigned to each group.
data.frame including the vector provided as argument in the original order ("value")
and the grouping vector ("rank"). If labels are provided as an argument, group labels
are also included in the data.frame ("labels").
Arguments
num_vector
numeric vector. It includes the values to be assigned to the different groups
groups
integer. The number of groups that will be generated
group_labels
character vector. Labels for each group. Note that
the length of group_labels has to be equal to the number of groups
desc
logical. If TRUE, the sorting is applied in a decreasing fashion