eval_conditions: Evaluate a Set of Logical Conditions Within a Data Frame

View source: R/eval_conditions.bare.R

eval_conditionsR Documentation

Evaluate a Set of Logical Conditions Within a Data Frame

Description

Evaluate each of a set of logical conditions within a data frame x. This is an internal utility function, not intended to be called directly by package users.

Usage

eval_conditions(x, conditions, NA_condition_value=TRUE)

Arguments

x

A data frame.

conditions

Character vector. Each element should represent an expression that can be evaluated within x, and produce a logical scalar or a vector with one value per row of x. Elements of conditions that are NA or the empty string are treated specially, via NA_condition_value.

NA_condition_value

Logical scalar, TRUE, FALSE, or NA. The value to use in place of evaluation when an element of conditions is NA or the empty string.

Details

Each condition should generally represent an expression involving columns of x. It is evaluated using x as the environment, and must return either a logical vector with length equal to the number of rows in x, or a logical scalar (which will be replicated into a vector of the right length). The resulting vectors, one per condition, form the columns of the returned matrix.

A condition may be NA or the empty string. In that case it is not evaluated, and a vector containing NA_condition_value is used instead.

Value

Logical matrix with one row for each row of x and one column for each condition in conditions. Element [i, j] contains the result of evaluating condition[j] for the i-th row of x.


tablesgg documentation built on June 22, 2024, 11:02 a.m.