cranvas (version 0.8.5)

mode_selection: Logical operations under different selection mode

Description

A selection mode is essentially a logical operation like AND, OR, and XOR, etc.

Usage

mode_selection(x, y, mode = "none")

Arguments

x
logical: the previous selection status
y
logical: the current selection status (if y is a numeric vector, it will be converted to a logical vector of the same length with x with TRUE's corresponding to the numeric indicies)
mode
the selection mode string; see Details

Value

a logical vector indicating whether the objects are selected

Details

There are five selection modes:
none
ignore previous selection and completely start over again
and
select the intersection, i.e. the objects that are selected by two successive brushing operations
or
select the union, i.e. any objects selected by all previous operations and the current operation
xor
toggle the selection
not
negation, i.e. exclude the objects under two successive brushing operations
complement
the complement of the current selection
We can hold the key while brushing: A for 'and', O for 'or', X for 'xor', N for 'not' and C for 'complement'.

See Also

&, |, xor, !

Examples

Run this code
x1 <- c(TRUE, TRUE, FALSE, FALSE)
x2 <- c(FALSE, TRUE, TRUE, FALSE)
mode_selection(x1, x2, "none")
mode_selection(x1, x2, "and")
mode_selection(x1, x2, "or")
mode_selection(x1, x2, "xor")
mode_selection(x1, x2, "not")
mode_selection(x1, x2, "complement")

mode_selection(x1, c(2, 3), "and")  # equivalent to x2

Run the code above in your browser using DataCamp Workspace