Similar to 'desc_groups' function, this one computes the rank of each value in order to quickly know what is the value in each segment that has the highest value (rank=1). 1 represent the highest number. It will exclude all factor/character variables.

desc_groups_rank(data, group_var, group_func = mean)

Arguments

data

input data source

group_var

variable to make the group by

group_func

the data type of this parameter is a function, not an string, this is the function to be used in the group by, the default value is: mean

Value

grouped data frame, showing the rank instead of the absolute values/

Examples

# default grouping function: mean desc_groups_rank(data=mtcars, group_var="gear")
#> gear mpg cyl disp hp drat wt qsec vs am carb #> 1 3 3 1 1 2 3 1 2 2 3 2 #> 2 4 1 3 3 3 1 3 1 1 2 3 #> 3 5 2 2 2 1 2 2 3 2 1 1
# using the median as the grouping function desc_groups(data=mtcars, group_var="cyl", group_func=median)
#> cyl mpg disp hp drat wt qsec vs am gear carb #> 1 4 26.0 108.0 91.0 4.080 2.200 18.90 1 1 4 2.0 #> 2 6 19.7 167.6 110.0 3.900 3.210 18.30 1 0 4 4.0 #> 3 8 15.2 350.5 192.5 3.120 3.750 17.18 0 0 3 3.5 #> 4 All_Data 19.2 196.3 123.0 3.695 3.325 17.71 0 0 4 2.0
# using the max as the grouping function desc_groups_rank(data=mtcars, group_var="gear", group_func=max)
#> gear mpg cyl disp hp drat wt qsec vs am carb #> 1 3 3 1 1 2 3 1 2 1 2 2 #> 2 4 1 2 3 3 1 3 1 1 1 2 #> 3 5 2 1 2 1 2 2 3 1 1 1