ballet: ballet

Description Usage Arguments Details Value Examples

View source: R/ballet.R

Description

ballet() iterates on the groups, as identified by dplyr::group_rows()), and applies the choreography() to each group.

Usage

1
ballet(.tbl, ..., .env = caller_env())

Arguments

.tbl

A data frame

...

Description of the columns to create, see choreography() for details.

.env

parent environment of the function generated by choreography()

Details

The grouping structure of .tbl defines the number of groups n_groups and the formulas in ... gives the number of dance moves n_moves

Value

a list of 2 elements

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
data <- iris %>%
  group_by(Species)

# most dance functions get the result of ballet()
# and then process it
c(ptypes, steps) %<-%
  ballet(data,
    Sepal.Length = ~mean(Sepal.Length),
    Sepal.Width  = ~mean(Sepal.Width)
  )
ptypes
steps

purrr::transpose(steps)
purrr::map_dbl(steps, 1)
purrr::map_dbl(steps, 2)

romainfrancois/dance documentation built on Nov. 21, 2019, 11:49 a.m.