top {PPLasso} | R Documentation |
Thresholding to 0
Description
This function keeps only the K largest values of the vector and sets the others to 0.
Usage
top(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(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,0)
}
[Package PPLasso version 2.0 Index]