max_n | R Documentation |
Returns elements of x
by position n
after sorting by, decreasing for max_n()
or increasing for min_n()
.
Any NA
elements of x
are ranked last for either function.
max_n(x, n = 2L)
min_n(x, n = 2L)
x |
A vector. |
n |
Numeric vector giving the ranks of elements to be returned. |
A vector of length equal to n
.
x <- 5:8
max_n(x, 2)
min_n(x, 1:2)
max_n(c(5:7, NA), 1:4)
min_n(c(5:7, NA), 1:4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.