logical_reducer {IssueTrackeR}R Documentation

Compute assertion

Description

This function allows the user to summarise a set of booleans into a single boolean via a logic gate.

Usage

logical_reducer(
  ...,
  orientation = c("vector-wise", "overall"),
  logic_gate = c("AND", "OR")
)

Arguments

...

Boolean objects that will be reduced into a single Boolean

orientation

a character string that is either "vector-wise" (by default) if you want to compute the assertion element by element (is ... contains vector of same length) or "overall" if you want to compute the assertion with all the element contained in ....

logic_gate

the logic operator which will aggregate the different assertion related to values: "OR" or "AND" (by default).

Details

Logic gates work with Booleans in the following way:

AND gate TRUE FALSE
TRUE TRUE FALSE
FALSE FALSE FALSE
OR gate TRUE FALSE
TRUE TRUE TRUE
FALSE TRUE FALSE

If the argument orientation is "overall", then all the element of ... will be computed together with logic gate provided by the argument logic_gate.

For example, the following call:

logical_reducer(
    TRUE, FALSE, c(TRUE, TRUE, TRUE),
    logic_gate = "AND", orientation = "overall"
)

will be return FALSE because the second argument (in ...) has the value FALSE and with the logic gate AND, the results is FALSE.

On the other hand, if the argument orientation is "vector-wise" then the element of ... must have the same length and their first element will be computed together then their second... and at the end their last element will be computed together with logic gate provided by the argument logic_gate.

For example, the following call:

logical_reducer(
    c(TRUE, TRUE, FALSE), c(FALSE, TRUE, FALSE),
    logic_gate = "OR", orientation = "vector-wise"
)

will be return c(TRUE, TRUE, FALSE) because the first argument (in ...) contains c(TRUE, TRUE) as first and second argument (so with the logic gate OR, the result is TRUE) and the third value of all element in ... is FALSE so the result is FALSE.

Value

a Boolean vector of length 1 if orientation is "overall" and of the same length as the elements contained in ... if orientation is "vector-wise".


[Package IssueTrackeR version 1.1.1 Index]