save_brush_history: Create the brush history

Description Usage Arguments Details Value Note Author(s) See Also Examples

View source: R/brush.R

Description

Given the indices of the brushed elements, this function stores these indices in the brush object and changes the colors of graphical elements permanently (via changing the .color column in the data) if in the persistent brushing mode.

Usage

1

Arguments

data

the mutaframe created by qdata

index

the indices of rows to be stored in history; an integer vector or a logical vector (will be coerced to integers by which); by default it is selected(data), i.e., the logical vector indicating which rows are brushed

Details

For the transient brushing: the given indices are stored in the history.list component of the brush object. The length of the list of indices is restricted by the history.size component of the brush, i.e., old histories may be removed due to this size restriction.

For the persistent brushing: the given indices of brushed elements are stored in the persistent.list component, and the current brushing color is also saved to the persistent.color component. The colors of brushed elements will be changed permanently. Finally, the length of the list of indices is also restricted by the history.size component of the brush.

We can use these stored information to redraw the brushed elements later. See brush for detailed explanation of these components.

Value

the data argument will be returned and other changes occur as side effects

Note

The changes occur only if the index argument is not empty, or when the data argument is in the persistent brushing mode, i.e., when brush(data, 'persistent') is TRUE. In this case, the returned data will be different with the one passed in, because the brush object attached on it has been changed.

Author(s)

Yihui Xie <http://yihui.name>

See Also

brush, qdata, selected

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
library(cranvas)
qnrc <- qdata(nrcstat)
selected(qnrc)  # all FALSE by default
selected(qnrc)[1:5] <- TRUE  # brush first 5 rows

b <- brush(qnrc)  # the brush object
b$history.list  # this list should be empty by default

save_brush_history(qnrc)  # store currently brushed row indices in history
save_brush_history(qnrc, c(6, 7, 10))  # another history

b$history.list  # what happened to the brush object?

b$persistent <- TRUE  # turn on persistent brushing
b$persistent.list  # this list should be empty by default too
save_brush_history(qnrc, c(3, 4, 6, 9))  # permanently brush other 4 rows

b$persistent.list  # what happened to the brush object?
b$persistent.color
b$color
b$history.list

ggobi/cranvas documentation built on May 17, 2019, 3:10 a.m.