R/max_sqr.R

Defines functions max_sqr

Documented in max_sqr

#' Find the maximum of the squared values.
#'
#' @param x Numeric vector
#'
#' @return Maximum of the squared values, or -Inf if all elements are NA.
#' @export
max_sqr = function(x) {
  # Handle missing data manually so we don't get warnings when it occurs.
  x = na.omit(x)
  if (length(x) == 0) {
    -Inf
  } else {
    max(x^2)
  }
}
ck37/varImpact documentation built on June 26, 2022, 4:02 a.m.