R/util.R

Defines functions sortrank

Documented in sortrank

## util.R
##
## miscellaneous utilities
##


sortrank <- function(x) {
  ## sort and rank data with one call to order()
  ## faster than calling sort and rank separately
  ## returns an object identical to:
  ##   list(x=sort(x), ix=order(x), r=rank(x, ties.method = "first"))
  o <- order(x)
  n <- length(o)
  N <- 1:n
  N[o] <- N
  return(list(x=x[o], ix=o, r=N))
}

Try the energy package in your browser

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

energy documentation built on Feb. 22, 2021, 5:08 p.m.