R/is-incomplete-terms.R

Defines functions is_incomplete_terms

Documented in is_incomplete_terms

#' Is Incomplete Terms
#'
#' Tests whether a term vector has absent elements.
#' The vector should not require repairing.
#'
#' @inheritParams params
#' @return A logical scalar indicating whether the object's terms are incomplete.
#' @seealso [term-vector()] and [complete_terms()]
#' @export
#'
#' @examples
#' is_incomplete_terms(term("b[2]"))
#' is_incomplete_terms(term("b[2]", "b[1]"))
#' is_incomplete_terms(term("b[2]", "b[1]", "b[1]"))
is_incomplete_terms <- function(x, ...) {
  x <- as_term(x)
  if (!length(x)) {
    return(FALSE)
  }
  if (anyNA(x)) {
    return(NA)
  }
  x <- unique(x)
  length(x) < sum(vapply(pdims(x), prod, 1))
}

Try the term package in your browser

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

term documentation built on Sept. 29, 2022, 5:14 p.m.