R/count_logical.R

Defines functions count_logical

Documented in count_logical

#' Count logicals
#' @description Count the number of \code{FALSE}, \code{TRUE}, and \code{NA}s.
#' @param x A logical vector.
#' @param nThread Number of threads to use.
#'
#' @return A vector of 3 elements: the number of \code{FALSE}, \code{TRUE}, and
#' \code{NA} values in \code{x}.
#'
#' @export

count_logical <- function(x, nThread = getOption("hutilscpp.nThread", 1L)) {
  if (!is.logical(x)) {
    stop("`x` was type ", typeof(x), ", but must be type logical.")
  }
  nThread <- check_omp(nThread)
  as_integer_if_safe(.Call("Ccount_logical", x, nThread, PACKAGE = packageName))
}

Try the hutilscpp package in your browser

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

hutilscpp documentation built on Oct. 11, 2023, 9:06 a.m.