vector_value_occurrences: Checks if a given value occurs a given number of times in a...

View source: R/vector.R

vector_value_occurrencesR Documentation

Checks if a given value occurs a given number of times in a vector

Description

Checks if a given value occurs a given number of times in a vector

Usage

vector_value_occurrences(
  vec,
  value,
  exact_occurrences = NULL,
  min_occurrences = NULL,
  max_occurrences = NULL
)

Arguments

vec

The vector to check

value

The value to check

exact_occurrences

the exact number of times the value must be present. Takes precedence over min/max_occurrences.

min_occurrences

the minimum number of times (inclusive) the value must be present.

max_occurrences

the maximum number of times (inclusive) the value must be present.

Examples

## Not run: 
# For assertion
assertthat::assert_that(
  qscheck::vector_value_occurrences(
    vec, value, min_occurrences = 2, max_occurrences = 3
  )
)
# For check
if (qscheck::vector_value_occurrences(
    vec, value, min_occurrences = 2, max_occurrences = 3
   )) {
}

## End(Not run)


AstraZeneca/qscheck documentation built on Nov. 1, 2023, 4:45 a.m.