R/mean_na.R

Defines functions mean_na

Documented in mean_na

#' Proportion of values that are NA.
#' @param v A vector.
#' @return A double, \code{mean(is.na(v))}.
#' @export

mean_na <- function(v) {
  if (anyNA(v)) {
    sum(is.na(v)) / length(v)
  } else {
    0
  }
}

Try the hutils package in your browser

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

hutils documentation built on April 13, 2022, 5:23 p.m.