File: linked_brush.Rd

package info (click to toggle)
r-cran-ggvis 0.4.7%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 1,716 kB
  • sloc: javascript: 7,373; sh: 25; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 1,265 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/linked_brush.R
\name{linked_brush}
\alias{linked_brush}
\title{Create a linked brush object.}
\usage{
linked_brush(keys, fill = "red")
}
\arguments{
\item{keys}{vector of all possible keys, if known.}

\item{fill}{brush colour}
}
\value{
A list with components:
  \item{input}{A function that takes a visualisation as an argument and
     adds an input brush to that plot}
  \item{selected}{A reactive providing a logical vector that describes
    which points are under the brush}
  \item{fill}{A reactive that gives the fill colour of points under the
    brush}
}
\description{
A linked brush has two sides: input and output
}
\note{
\code{linked_brush} is very new and is likely to change substantially
  in the future
}
\examples{
lb <- linked_brush(keys = 1:nrow(mtcars), "red")

# Change the colour of the points
mtcars \%>\%
 ggvis(~disp, ~mpg) \%>\%
 layer_points(fill := lb$fill, size.brush := 400) \%>\%
 lb$input()

# Display one layer with all points and another layer with selected points
library(shiny)
mtcars \%>\%
 ggvis(~disp, ~mpg) \%>\%
 layer_points(size.brush := 400) \%>\%
 lb$input() \%>\%
 layer_points(fill := "red", data = reactive(mtcars[lb$selected(), ]))
}