Skip to content
Yihui Xie edited this page Dec 18, 2010 · 1 revision

Selection (Brushing) Modes

Implementation

Currently, different brushing modes are mainly generated from the function mode_selction() under utilities/interaction.r. See the documentation therein. Here are some examples:

# x1: previous selection status
# x2: current selection
> x1 = c(TRUE, TRUE, FALSE, FALSE)
> x2 = c(FALSE, TRUE, TRUE, FALSE)
> mode_selection(x1, x2, 'none')
[1] FALSE  TRUE  TRUE FALSE
> mode_selection(x1, x2, 'and')
[1] FALSE  TRUE FALSE FALSE
> mode_selection(x1, x2, 'or')
[1]  TRUE  TRUE  TRUE FALSE
> mode_selection(x1, x2, 'xor')
[1]  TRUE FALSE  TRUE FALSE
> mode_selection(x1, x2, 'not')
[1]  TRUE FALSE FALSE FALSE
> mode_selection(x1, x2, 'complement')
[1]  TRUE FALSE FALSE  TRUE
## or with 0-1 notation
> sapply(data.frame(x1 = x1, x2 = x2,
+ none = mode_selection(x1, x2, 'none'),
+ and = mode_selection(x1, x2, 'and'),
+ or = mode_selection(x1, x2, 'or'),
+ xor = mode_selection(x1, x2, 'xor'),
+ not = mode_selection(x1, x2, 'not'),
+ complement = mode_selection(x1, x2, 'complement')), as.integer)
     x1 x2 none and or xor not complement
[1,]  1  0    0   0  1   1   1          1
[2,]  1  1    1   1  1   0   0          0
[3,]  0  1    1   0  1   1   0          0
[4,]  0  0    0   0  0   0   0          1

Discussion

Naming conventions

We have not agreed with each other on the names -- two possible sets:

  • none, and, or, xor, not, complement
  • basic/replace, intersection, union, toggle, flip, complement

The problem is, the end users may not understand or care about Boolean operations in the first set. Besides, and might be confusing to them (need to think of it as the & operator instead of an ordinary English word!).

(Yihui: I prefer the first set because (1) names are shorter, so easier to code (2) Boolean operations are really what's going on behind the scene instead of set operations (3) the users will not really worry about the names in the future because we will surely have a GUI for them, in which we can write tooltips for them to understand these options. For the current stage, I do not think this is an important issue.)

Colors of the brushed objects

For the time being, we are using a single color for all the brushed objects. Di is thinking about different colors.

(Yihui: this is not an issue in terms of implementation; we can add another row attribute to store colors for the brushed objects.)

Selection sequences

(Yihui: if I understand correctly, selection sequences were already there before our discussion. We can select some rows in one plot and use different selection mode in other plots to do different Boolean operations.)