R: Verbal Logic

verbalogic {spatstat.utils} | R Documentation

## Verbal Logic

### Description

Perform the specified logical operation on the character vector `x`, recognising the special strings `"TRUE"` and `"FALSE"` and treating other strings as logical variables.

### Usage

    verbalogic(x, op = "and")

### Arguments

`x` | Character vector.
`op` | Logical operation: one of the character strings `"and"`, `"or"` or `"not"`.

### Details

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.

### Value

A character string.

### Author(s)

Adrian Baddeley Adrian.Baddeley@curtin.edu.au.

### Examples

       x <- c("The sky is blue", "my name is not Einstein", "FALSE")
       verbalogic(x, "and")
       verbalogic(x, "or")
       verbalogic(x, "not")

[Package spatstat.utils version 1.17-0 Index]