cranvas (version 0.8.5)

save_brush_history: Create the brush history

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

save_brush_history(data, index = selected(data))

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

Value

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

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.

See Also

brush, qdata, selected

Examples

Run this code
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

Run the code above in your browser using DataLab