tango: Summarise one row per group

Description Usage Arguments Examples

Description

Applies the ballet() and makes sure each results is of size 1, according to vctrs::vec_size()

Usage

1
2
3
4
5
6
7
tango(.tbl, ..., .env = caller_env())

waltz(.tbl, ..., .env = caller_env())

polka(.tbl)

charleston(.tbl, ..., .name = "data", .env = caller_env())

Arguments

.tbl

A data frame, most likely a grouped data frame

..., .env

formulas for each column to create, and parent environment, see ballet()

.name

Name of the packed column made by charleston()

The four functions play a separate role around the idea of dplyr::summarise():

  • polka() peels off one level of grouping from the grouping variable, i.e. if .tbl was grouped by x and y the result of polka() contains columns x and y and is only grouped by x

  • waltz() runs the ballet() defined by ... and makes sure each result is of vctrs::vec_size() 1. The result tibble of waltz() does not contain the grouping variables.

  • tango() is the closest to dplyr::summarise(), it column binds the result of polka() and waltz() with vctrs::vec_cbind().

  • charleston() is similar to tango() but the results are packed instead of being bind. The name of the created packed column is controled by the .name argument.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
g <- group_by(iris, Species)

polka(g)

g %>%
  waltz(Sepal = ~mean(Sepal.Length * Sepal.Width))

g %>%
  tango(Sepal = ~mean(Sepal.Length * Sepal.Width))

g %>%
  charleston(Sepal = ~mean(Sepal.Length * Sepal.Width))

romainfrancois/dance documentation built on May 14, 2019, 11:07 p.m.