trelliscopejs (version 0.1.11)

by_row_plot: Apply a function to each row of a data frame and return a data frame with new column of plots

Description

Apply a function to each row of a data frame and return a data frame with new column of plots

Usage

by_row_plot(.d, ..f, .to = "panel")

Arguments

.d

A data frame.

..f

A function to apply to each row. It should return a valid panel object (such as a ggplot2 / lattice / htmlwidget object).

.to

Name of output column (defaults to "panel").

Details

See by_row

Examples

Run this code
# NOT RUN {
library(tidyr)
library(purrr)
library(rbokeh)
iris %>%
  nest(-Species) %>%
  mutate(mod = map(data, ~ lm(Sepal.Length ~ Sepal.Width, data = .x))) %>%
  by_row_panel(function(x) {
    figure(xlab = "Sepal.Width", ylab = "Sepal.Length") %>%
      ly_points(x$data[[1]]$Sepal.Width, x$data[[1]]$Sepal.Length) %>%
      ly_abline(x$mod[[1]])
  }) %>%
  trelliscope(name = "iris")
# }

Run the code above in your browser using DataCamp Workspace