This function performs simple logical operations
on character strings that represent human-readable statements.
The character vector x
may contain any strings:
the special strings "TRUE"
and "FALSE"
are
treated as the logical values TRUE
and FALSE
,
while all other strings are treated as if they were
logical variables.
If op="and"
, the result is a single string,
logically equivalent to x[1] && x[2] && ... && x[n]
.
First, any entries of x
equal to "TRUE"
are removed.
The result is "FALSE"
if any of the entries of x
is "FALSE"
; otherwise it is equivalent to
paste(x, collapse=" and ")
.
If op="or"
, the result is a single string, logically equivalent to
x[1] || x[2] || ... || x[n]
.
First, any entries of x
equal to "FALSE"
are removed.
The result is "TRUE"
if any of the entries of x
is "TRUE"
; otherwise it is equivalent to
paste(x, collapse=" or ")
.
If op="not"
, the result is a character vector y
such that y[i]
is the logical negation of x[i]
.
The code does not understand English grammar and cannot expand logical
expressions.