A helper function -- tie-robust-rank cut-off
tieRobustRankLessOrEqual(numvec, nth)
numvec | A numeric vector |
---|---|
nth | A single number (a constant i.e. vector of length 1) |
A logical vector of the same length as numvec
x <- c(1,1,2,2,2,3,3) p <- function(d) # Just for clarity print(`colnames<-`(d, paste0(colnames(d),' ')), right=FALSE, row.names=FALSE) p(data.frame(x, rank(x) <= 2, tieRobustRankLessOrEqual(x, 2), check.names = FALSE))#> x rank(x) <= 2 tieRobustRankLessOrEqual(x, 2) #> 1 TRUE TRUE #> 1 TRUE TRUE #> 2 FALSE TRUE #> 2 FALSE TRUE #> 2 FALSE TRUE #> 3 FALSE FALSE #> 3 FALSE FALSE