Description Usage Arguments Details Value Note Author(s) See Also Examples
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.
1 | save_brush_history(data, index = selected(data))
|
data |
the mutaframe created by |
index |
the indices of rows to be stored in history; an integer vector
or a logical vector (will be coerced to integers by
|
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.
the data
argument will be returned and other changes occur as
side effects
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.
Yihui Xie <http://yihui.name>
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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.