top_thresh: Thresholding to a given threshold of the smallest values

View source: R/top_thresh.R

top_threshR Documentation

Thresholding to a given threshold of the smallest values

Description

This function keeps only the K largest values of the vector and sets the others to the smallest value among the K largest.

Usage

top_thresh(vect,thresh)

Arguments

vect

vector to threshold

thresh

threshold

Value

This function returns the thresholded vector.

Author(s)

Wencan Zhu, Celine Levy-Leduc, Nils Ternes

Examples

x=sample(1:10,10)
thresh=3
top_thresh(x,thresh)

## The function is currently defined as
function (vect, thresh) 
{
    sorted_vect <- sort(abs(vect),decreasing=TRUE)
    v = sorted_vect[thresh]
    ifelse(abs(vect) >= v, vect, v)
  }

PPLasso documentation built on March 7, 2023, 6:33 p.m.