R/count_missing.R

Defines functions count_missing

Documented in count_missing

#' @title Count Missing Values in a Vector
#'
#' @description
#' Same as `sum(is.na(x))`, but without the allocation.
#'
#' @param x [`vector()`]\cr
#'   Supported are logical, integer, double, complex and string vectors.
#' @return (`integer(1)`) number of missing values.
#'
#' @useDynLib mlr3misc c_count_missing
#' @export
#' @examples
#' count_missing(c(1, 2, NA, 4, NA))
count_missing = function(x) {
  .Call(c_count_missing, x, PACKAGE = "mlr3misc")
}
mlr-org/mlr3misc documentation built on April 28, 2024, 11 p.m.