R/which_true_onwards.R

Defines functions which_true_onwards

Documented in which_true_onwards

#' At which point are all values true onwards
#' @param x A logical vector. \code{NA} values are not permitted.
#' @return The position of the first \code{TRUE} value in \code{x} at which all
#' the following values are \code{TRUE}.
#'
#' @examples
#' which_true_onwards(c(TRUE, FALSE, TRUE, TRUE, TRUE))
#'
#' @export

which_true_onwards <- function(x) {
  if (!is.logical(x)) {
    stop("`x` was type ", class(x), ". `x` must be a logical vector.")
  }
  if (anyNA(x)) {
    stop("`x` had missing values. This is not permitted.")
  }

  .Call("Cwhich_true_onwards", x, 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.