R/rank.ub.average.R

Defines functions rank.ub.average

Documented in rank.ub.average

#' Percentile rank transformation of a vector
#'
#' A function that performs the Percentile rank transformation of a vector
#'
#' @param x A numeric vector.
#' @return Returns the percentile rank of each element.
#' @examples
#' rank.ub.average(1:10)
#' @export
rank.ub.average <- function(x){
  n <- length(unique(x))
  N <- length(x)
  if(n==1){x <- rep(NA,N)}
  if(n>1){x  <- (rank(x,ties.method="average")-1)/(N-1)*100}
  return(x)
}

Try the CytoDx package in your browser

Any scripts or data that you put into this service are public.

CytoDx documentation built on Nov. 8, 2020, 11 p.m.