trelliscopejs (version 0.1.13)

map_plot: Apply a function to each element of a vector and return a vector of plots

Description

Apply a function to each element of a vector and return a vector of plots

Usage

map_plot(.x, .f, ...)

Arguments

.x

a list or atomic vector (see map for details)

.f

a function, formula, or atomic vector (see map for details)

...

additional arguments passed on to .f (see map for details)

Details

See map

Examples

Run this code
# NOT RUN {
library(dplyr)
library(tidyr)
library(purrr)
library(rbokeh)
library(gapminder)

# nest gapminder data by country
by_country <- gapminder %>%
  group_by(country, continent) %>%
  nest()

# add in a plot column with map_plot
by_country <- by_country %>% mutate(
  panel = map_plot(data,
    ~ figure(xlim = c(1948, 2011), ylim = c(10, 95), width = 300, tools = NULL) %>%
        ly_points(year, lifeExp, data = .x, hover = .x)
  ))

# plot it
by_country %>%
  trelliscope("gapminder", nrow = 2, ncol = 7)

library(dplyr)
library(tidyr)
ggplot2::mpg %>%
  group_by(manufacturer, class) %>%
  nest() %>%
  mutate(panel = map_plot(data,
    ~ figure(xlab = "City mpg", ylab = "Highway mpg") %>%
        ly_points(cty, hwy, data = .x))) %>%
  trelliscope(name = "city_vs_highway_mpg")
# }

Run the code above in your browser using DataLab