getKminmax: Get the k largest/smallest elements

Description Usage Arguments Details Value Author(s) References Examples

View source: R/getKminmax.R

Description

Extract the k largest or smallest values and their indices for each column of a matrix.

Usage

1
getKminmax(x, k, flag = "max")

Arguments

x

a data matrix or data frame.

k

an integer specifying the number of extreme values. Must be <= nrows(x).

flag

use "min" or "max" (default) to select smallest or largest elements.

Details

Order the values of each column of x and determine the k smallest (flag = "min") or largest (flag = "max") values and their indices. NA's in the data are ignored.

Value

List with elements:

ik

indices of ordered extreme values

minmax

ordered extreme values.

Author(s)

Ariane Schad

References

Brombacher, E., Schad, A., Kreutz, C. (2020). Tail-Robust Quantile Normalization. BioRxiv.

Examples

1
2
3
4
# Create a data matrix
x <- matrix(c(5,2,3,NA,4,1,4,2,3,4,6,NA,1,3,1),ncol=3)
# Get indices of the 5 largest values in each column
getKminmax(x, k = 5, "max") 

MBQN documentation built on Nov. 8, 2020, 8:13 p.m.