R/getMaxIndex.R

Defines functions getMaxIndex

getMaxIndex <- function(values, Names, k = 2) {
  
  val <- abs(values)
  n <- length(val)
  
  
  if(missing(Names)) Names <- seq_len(n)
  if(k < 1) return(rep('', n))
  if(k > n) return(Names)
  
  out <- rep('', n)
  
  for(i in 1:k) {
    id <- which.max(val)
    out[id] <- Names[id]
    val[id] <- NA
  }
  out 
}

Try the glmxdiag package in your browser

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

glmxdiag documentation built on Jan. 10, 2022, 9:07 a.m.