jive: Modify

Description Usage Arguments Value Examples

Description

Applies the ballet() with no restriction on the vec_size() of the outputs.

Usage

1
2
3
4
5
foxtrot(.tbl, ..., .env = caller_env())

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

jive(.tbl, ..., .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 bachata()

Value

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
g <- group_by(iris, Species)

## Not run: 
if (requireNamespace("broom", quietly = TRUE)) {
  ### foxtrot() to return a list of tibbles

  # A list of tibbles with the `quantiles` column derived from the
  # formula on each group
  g %>%
    foxtrot(
      quantiles = ~quantile(Petal.Length, probs = c(0.25, 0.5, 0.75))
    )

  g %>%
    foxtrot(
      ~ broom::tidy(lm(Petal.Length ~ Sepal.Length))
    )

  ### bachata() to nest the results of foxtrot()

  # bachata() = polka() + a list column of 2 columns tibbles
  g %>%
    bachata(
       Sepal.Length = ~quantile(Sepal.Length, probs = c(0.25, 0.5, 0.75)),
       Sepal.Width  = ~quantile(Sepal.Width, probs = c(0.25, 0.5, 0.75)),
    )

  # because the formula is unnamed, the columns of the tibbles
  # generated by broom::tidy() are auto-spliced
  g %>%
    bachata(
      ~ broom::tidy(lm(Petal.Length ~ Sepal.Length))
    )

  ### jive()
  g %>%
    jive(
       Sepal.Length = ~quantile(Sepal.Length, probs = c(0.25, 0.5, 0.75)),
       Sepal.Width  = ~quantile(Sepal.Width, probs = c(0.25, 0.5, 0.75)),
    )

  # unnamed -> columns are spliced
  g %>%
    jive(
      ~ broom::tidy(lm(Petal.Length ~ Sepal.Length))
    )

  # named -> packed column
  g %>%
    jive(
      model = ~ broom::tidy(lm(Petal.Length ~ Sepal.Length))
    )
}

## End(Not run)

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