top_thresh | R Documentation |
This function keeps only the K largest values of the vector and sets the others to the smallest value among the K largest.
top_thresh(vect,thresh)
vect |
vector to threshold |
thresh |
threshold |
This function returns the thresholded vector.
Wencan Zhu, Celine Levy-Leduc, Nils Ternes
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) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.