rankDF: Convert a data frame to ranks

Description Usage Arguments Value See Also Examples

View source: R/coin_resultstable.R

Description

Replaces all numerical columns of a data frame with their ranks. Uses sport ranking, i.e. ties share the highest rank place. Ignores non-numerical columns. See rank(). Optionally, returns in-group ranks using a specified grouping column.

Usage

1
rankDF(df, use_group = NULL)

Arguments

df

A data frame

use_group

An optional column of df (specified as a string) to use as a grouping variable. If specified, returns ranks inside each group present in this column.

Value

A data frame equal to the data frame that was input, but with any numerical columns replaced with ranks.

See Also

Examples

1
2
3
4
5
6
7
8
# some random data, with a column of characters
df <- data.frame(RName = c("A", "B", "C"),
Score1 = runif(3), Score2 = runif(3))
# convert to ranks
rankDF(df)
# grouped ranking - use some example data
df1 <- ASEMIndData[c("UnitCode", "Group_GDP", "Goods", "LPI")]
rankDF(df1, use_group = "Group_GDP")#'

COINr documentation built on Nov. 30, 2021, 9:06 a.m.