trelliscopejs (version 0.1.11)

by_row_cog: Apply a function to each row of a data frame and return a data frame with new column of cognostics

Description

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

Usage

by_row_cog(.d, ..f, .to = NULL)

Arguments

.d

A data frame.

..f

A function to apply to each row. It should return a single-row data frame of cognostics

.to

Name of output column (defaults to "cogs" or if "cogs" exists, "cogs1", etc.).

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))) %>%
  panels_by_row(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 DataLab