Description Usage Arguments Details See Also Examples
swing()
: returns a spliced list of formulas, suitable for the
...
argument of choreography()
, as well as all the dances that
use a choreography()
1 2 3 4 5 |
.fun |
A function or a formula that uses |
... |
tidy selection of columns, see |
.tbl, .env |
data frame |
.name |
|
twist()
: returns a single formula that makes a tibble column
These functions are generally used within other dances, such as
tango()
, samba()
or jive()
rumba()
and zumba()
to apply several functions to the same column
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 | g <- iris %>% group_by(Species)
##------- tango()
# Apply mean to all columns that start with Sepal
# and choose how the result columns are called
g %>%
tango(
swing(mean, starts_with("Sepal"), .name = "mean_{var}")
)
# if you want to use extra arguments of `.fun` you can embed
# them with the lambda syntax
g %>%
tango(
swing(~mean(., trim = .2), starts_with("Sepal"), .name = "mean_{var}")
)
# use twist() to instead create a single packed column
g %>%
tango(
mean = twist(mean, starts_with("Sepal"))
)
# but in fact, if you don't name the formula made by twist()
# the columns are auto spliced
g %>%
tango(
twist(mean, starts_with("Sepal"))
)
##------- samba()
g %>%
samba(
swing(~. - mean(.), starts_with("Sepal"), .name = "centered_{var}")
)
g %>%
samba(
centered = twist(~. - mean(.), starts_with("Sepal"), .name = "centered_{var}")
)
##------- jive()
g %>%
jive(
q = ~ c("25%", "50%", "75%"),
swing(~quantile(., c(0.25, 0.5, 0.75)), contains("."))
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.