top_thresh {WLogit}R Documentation

Thresholding to a given threshold of the smallest values

Description

This function keeps only the K largest values of the vector vect 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)
sorted_vect=sort(x,decreasing=TRUE)
thresh=3
top_thresh(x,thresh)

##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

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

[Package WLogit version 2.1 Index]