slam: pmap adapter

Description Usage Arguments Examples

Description

slam() is typically used in purrr::pmap() calls to transform a formula that uses the raw names into a function. slam() is not quite rap().

Usage

1
slam(.tbl, formula)

Arguments

.tbl

a tibble

formula

a formula that uses columns from the tibble

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
library(purrr)
library(gapminder)
library(dplyr)

oceania <- gapminder::gapminder %>%
  filter(continent == "Oceania") %>%
  mutate(yr1952 = year - 1952) %>%
  select(-continent) %>%
  group_nest(country)

# the idea of slam is to promote a formula expressed with the
# column names into a pmap() ready function
formula <- ~broom::tidy(stats::lm(lifeExp ~ yr1952, data))
oceania %>%
  pmap(slam(oceania, formula))

# this is similar to e.g.
oceania %>%
  wap(~broom::tidy(stats::lm(lifeExp ~ yr1952, data)))

romainfrancois/rap documentation built on June 8, 2019, 5:42 p.m.