is_condition: Check whether a list of character vectors contains valid...

View source: R/is_condition.R

is_conditionR Documentation

Check whether a list of character vectors contains valid conditions

Description

A valid condition is a character vector of predicate names, where each predicate corresponds to a column name in a given data frame or matrix. This function verifies that each element of a list x contains only valid predicates that match column names of data.

Usage

is_condition(x, data)

Arguments

x

A list of character vectors, each representing a condition.

data

A matrix or data frame whose column names define valid predicates.

Details

Special cases:

  • An empty character vector (character(0)) is considered a valid condition and always passes the check.

  • A NULL element is treated the same as an empty character vector, i.e., it is also a valid condition.

Value

A logical vector with one element for each condition in x. An element is TRUE if the corresponding condition is valid, i.e. all of its predicates are column names of data. Otherwise, it is FALSE.

Author(s)

Michal Burda

See Also

remove_ill_conditions(), format_condition()

Examples

d <- data.frame(foo = 1:5, bar = 1:5, blah = 1:5)

is_condition(list("foo"), d)
is_condition(list(c("bar", "blah"), NULL, c("foo", "bzz")), d)


nuggets documentation built on Nov. 5, 2025, 6:25 p.m.