Learn R Programming

PhysioIndexR (version 0.1.0)

ranking: Flexible Ranking Utility

Description

A thin wrapper around base rank with support for ascending/descending order, multiple tie strategies, NA placement, and dense ranks.

Usage

ranking(
  v,
  direction = c("asc", "desc"),
  ties = c("average", "min", "max", "first", "random"),
  na.last = c("keep", "bottom", "top"),
  dense = FALSE
)

Value

An integer/numeric vector of ranks, same length as v.

Arguments

v

Numeric (or coercible) vector to rank.

direction

Character, one of "asc" or "desc".

ties

Character, tie-breaking: one of "average", "min", "max", "first", "random".

na.last

Character, placement of NAs: "keep", "bottom", or "top".

dense

Logical; if TRUE, returns dense ranks (1,2,3,...) without gaps.

Examples

Run this code
ranking(c(3, 3, 2, NA, 5), direction="asc", ties="min", na.last="bottom")
ranking(c(3, 3, 2, 5), direction = "desc", dense = TRUE)
Gen=c("G1","G2","G3")
YN=c(10,8,5)
YS=c(7,5,3)
a=STI(Gen, YN, YS) # for instance STI taken here.
out=data.frame(a$Result$Gen, a$Result$STI,
ranking(a$Result$STI, direction="desc")
)
print(out)

Run the code above in your browser using DataLab