Skip to contents

Select elements based on their ranking.

Usage

selectByRanking(
  x,
  k = length(x),
  method = c("auto", "shell", "quick", "radix"),
  decreasing = TRUE,
  use.abs = FALSE
)

Arguments

x

numerical vector.

k

integer value indicating the number of top elements to keep.

method

character string indicating the method used for sorting (see sort).

decreasing

logical indicating whether to sort in decreasing order.

use.abs

logical indicating whether to use absolute values.

Value

A logical vector indicating the elements to keep.

Author

Alessandro Barberis

Examples

#Seed
set.seed(1010)

#Data
x = seq(10)
names(x) = paste0("f", seq(10))

#Select
selectByRanking(x = x, k = 5)
#>    f1    f2    f3    f4    f5    f6    f7    f8    f9   f10 
#> FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE