Index, based on rank.

Description

Convert x to an index in 1... maxindex

Usage

1
rkindex(x, maxindex = length(x), pwr = 1, ties.method = "random", id)

Arguments

x

A vector of data to covert.

maxindex

Maximum for result

pwr

See details.

ties.method

passed to rank.

id

A string to be passed as id argument. If missing, an id will be generated from the arguments.

Details

x is transformed to a rank scale, using ties.method. It is then rescaled to [0,1], and (optionally) a power transformation is applied. In visualisation terms, this is a gamma correction. The result is rescaled to 1 ... maxindex.

Value

A vector of rescaled values.

Author(s)

G√ľnther Sawitzki <gsawitzki@users.r-forge.r-project.org>

Examples

1
2
3
4
5
 x <- runif(7)
 x
 str(rkindex(x, maxindex=5))
 str(rkindex(x, maxindex=5, pwr=0.5))
 

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.