Learn R Programming

ggvis (version 0.4.1)

linked_brush: Create a linked brush object.

Description

A linked brush has two sides: input and output

Usage

linked_brush(keys, fill = "red")

Arguments

keys
vector of all possible keys, if known.
fill
brush colour

Value

  • A list with components:
  • inputA function that takes a visualisation as an argument and adds an input brush to that plot
  • selectedA reactive providing a logical vector that describes which points are under the brush
  • fillA reactive that gives the fill colour of points under the brush

Examples

Run this code
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(), ]))

Run the code above in your browser using DataLab