Learn R Programming

DNAprofiles (version 0.3.1)

find.kth.element: Quickly finds the k'th largest element in a (large) vector

Description

Quickly finds the k'th largest element in a (large) vector

Usage

find.kth.element(x, k)

Arguments

x
Numeric vector.
k
Integer with the rank of the desired element.

Value

numeric k'th largest element

Examples

Run this code
y <- rnorm(1e3)
           stopifnot(identical(y[order(y,decreasing=TRUE)[100]],
                               find.kth.element(y,100)))

Run the code above in your browser using DataLab