isIncluded: Check if a vector of values is included in another vector of...

View source: R/error-checks.R

isIncludedR Documentation

Check if a vector of values is included in another vector of values

Description

Check if a vector of values is included in another vector of values

Usage

isIncluded(values, parentValues)

Arguments

values

A vector of values.

parentValues

A vector of values where values are checked for inclusion.

Value

Returns TRUE if the value or all values (if it's a vector) are present in the parentValues; FALSE otherwise.

Examples

# check if a column is present in dataframe
A <- data.frame(
  col1 = c(1, 2, 3),
  col2 = c(4, 5, 6),
  col3 = c(7, 8, 9)
)
isIncluded("col3", names(A)) # TRUE

# check if single element is present in a vector (atomic or non-atomic)
isIncluded("x", list("w", "x", 1, 2)) # TRUE
isIncluded("x", c("w", "a", "y")) # FALSE

# check if **all** values (if it's a vector) are contained in parent values
isIncluded(c("x", "y"), c("a", "y", "b", "x")) # TRUE
isIncluded(list("x", 1), list("a", "b", "x", 1)) # TRUE
isIncluded(c("x", "y"), c("a", "b", "x")) # FALSE
isIncluded(list("x", 1), list("a", "b", "x")) # FALSE

ospsuite.utils documentation built on March 18, 2022, 6:44 p.m.