dplyr-ggvis: Dplyr verbs for ggvis.

Description Usage Examples

Description

Reactive components must be wrapped in eval - this makes it possible to separate out the non-standard evaluation of dplyr and ggvis.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
groups.ggvis(x)

regroup.ggvis(x, value)

ungroup.ggvis(x)

summarise.ggvis(.data, ...)

mutate.ggvis(.data, ...)

arrange.ggvis(.data, ...)

select.ggvis(.data, ...)

## S3 method for class 'ggvis'
filter(.data, ...)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
library(dplyr)
base <- mtcars %>% ggvis(~mpg, ~cyl) %>% layer_points()
base %>% group_by(cyl) %>% summarise(mpg = mean(mpg)) %>%
  layer_points(fill := "red", size := 100)

base %>% filter(mpg > 25) %>% layer_points(fill := "red")

base %>% mutate(cyl = jitter(cyl)) %>% layer_points(fill := "red")

# Dynamically restrict range using filter
mtcars %>% ggvis(~disp, ~mpg) %>%
   filter(cyl > eval(input_slider(0, 10))) %>%
   layer_points()

# Dynamically compute box-cox transformation with mutate
bc <- function(x, lambda) {
  if (abs(lambda) < 1e-6) log(x) else (x ^ lambda - 1) / lambda
}
bc_slider <- input_slider(-2, 2, 1, step = 0.1)
mtcars %>%
 ggvis(~disp, ~mpg) %>%
 mutate(disp = bc(disp, eval(bc_slider))) %>%
 layer_points()

rpruim/ggvis2 documentation built on May 28, 2019, 2:34 a.m.