R/BAL.R

Defines functions PBAL

Documented in PBAL

 

PBAL <-  function(BA){

  ord.x <- order(BA)
  BAo <- sum(BA[ord.x]) - cumsum(BA[ord.x])
  ## ties
  is.tie <- rev(duplicated(BA[order(BA, decreasing = TRUE)]))
  BAo[is.tie] <- BAo[is.tie] - BA[ord.x][is.tie]
  ## return it to the original form
  BAo <- BAo[match(1:length(BAo), ord.x)]
  return(BAo)
}

Try the sitreeE package in your browser

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

sitreeE documentation built on Nov. 24, 2021, 1:13 a.m.