Rfast (version 1.7.3)

The nth largest value of a vector: The nth largest value of a vector

Description

The nth largest value of a vector.

Usage

nth(x, k)

Arguments

x
A numerical vector.
k
The kth largest number to be returned.

Value

The desired value.

Details

The function is written in C++ and this is why it is very fast. This is called (and used) by colMedians.

See Also

med, colMedians

Examples

Run this code
x <- rnorm(10000)
nth(x, 5000)
sort(x)[5000]

Run the code above in your browser using DataCamp Workspace