Description Usage Arguments Examples
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()
.
1 |
.tbl |
a tibble |
formula |
a formula that uses columns from the tibble |
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)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.