Returns the n maximum or n minimum values of a vector.

n_max(vec, n = 5)

n_min(vec, n = 5)

Arguments

vec

A vector from which to select the max or min values.

n

The number of values to return.

Value

The n max or min values of your vector.

Author

Emily E. Burke

Examples


x <- rnorm(100)
n_max(x)
#> [1] 1.774904 1.585633 1.548295 1.530684 1.432115
n_min(x)
#> [1] -2.912304 -2.701623 -2.335116 -2.142588 -1.476763