R/max_ninf.R

Defines functions max_ninf

Documented in max_ninf

#' Auxiliary Internal Functions
#'
#' @rdname n_elecfuns
#' @param x Numeric vector 
#'
#' @return The maximum of a vector, after removing non-finite elements
#'
#' 
#' 
max_ninf <- function(x){
  if(any(is.infinite(x))){
    if(all(!is.finite(x)) | all(is.na(x))){
      return(-Inf)
    } else {
      return(max(x[-which(is.infinite(x))], na.rm=TRUE))
    }
  } else {
    return(max(x, na.rm=TRUE))
  }
}

Try the i3pack package in your browser

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

i3pack documentation built on June 8, 2025, 11:43 a.m.