Learn R Programming

iNZightTools (version 1.13.0)

rankVars: Rank the data of a numeric variables

Description

Rank the values of a numeric variable in descending order, and returns the result along with tidyverse code used to generate it. Ties are broken as such: eg. values = 5, 6, 6, 7 ; rank = 1, 2, 2, 3

Usage

rankVars(.data, vars)

Value

the original dataframe containing new columns with the ranks of the variables in var with tidyverse code attached

Arguments

.data

a dataframe with the variables to rank

vars

a character vector of numeric variables in .data to rank

Author

Owen Jin

See Also

code

Examples

Run this code
ranked <- rankVars(iris, vars = c("Sepal.Length", "Petal.Length"))
cat(code(ranked))
head(ranked)

Run the code above in your browser using DataLab