ggvis (version 0.4.9)

dplyr-ggvis: Dplyr verbs for ggvis.

Description

Applying a dplyr verb to a ggvis object creates a reactive transformation: whenever the underlying data changes the transformation will be recomputed.

Usage

# S3 method for ggvis
groups(x)

# S3 method for ggvis group_by(.data, ..., .add = FALSE)

# S3 method for ggvis ungroup(x, ...)

# S3 method for ggvis summarise(.data, ...)

# S3 method for ggvis mutate(.data, ...)

# S3 method for ggvis arrange(.data, ...)

# S3 method for ggvis select(.data, ...)

filter.ggvis(.data, ...)

# S3 method for ggvis distinct(.data, ...)

# S3 method for ggvis slice(.data, ...)

# S3 method for ggvis rename(.data, ...)

# S3 method for ggvis transmute(.data, ...)

# S3 method for reactive groups(x)

# S3 method for reactive ungroup(x, ...)

# S3 method for reactive group_by(.data, ..., add = FALSE)

# S3 method for reactive summarise(.data, ...)

# S3 method for reactive mutate(.data, ...)

# S3 method for reactive arrange(.data, ...)

# S3 method for reactive select(.data, ...)

filter.reactive(.data, ...)

# S3 method for reactive distinct(.data, ...)

# S3 method for reactive slice(.data, ...)

# S3 method for reactive rename(.data, ...)

# S3 method for reactive transmute(.data, ...)

Arguments

Non-standard evaluation

Both dplyr and shiny do non-standard evaluation, so to help each package figure out when it should evaluate its code, reactive components in these functions must be wrapped in eval().

Examples

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

if (FALSE) {
# 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()
}

Run the code above in your browser using DataLab