verbalogic | R Documentation |
Perform the specified logical operation
on the character vector x
, recognising the
special strings "TRUE"
and "FALSE"
and treating other strings as logical variables.
verbalogic(x, op = "and")
x |
Character vector. |
op |
Logical operation: one of the character strings
|
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.
A character string.
.
x <- c("The sky is blue", "my name is not Einstein", "FALSE")
verbalogic(x, "and")
verbalogic(x, "or")
verbalogic(x, "not")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.