arrange_all: Arrange rows by a selection of variables

Description Usage Arguments Examples

Description

These scoped variants of arrange() sort a data frame by a selection of variables. Like arrange(), you can modify the variables before ordering with funs().

Usage

1
2
3
4
5
arrange_all(.tbl, .funs = list(), ..., .by_group = FALSE)

arrange_at(.tbl, .vars, .funs = list(), ..., .by_group = FALSE)

arrange_if(.tbl, .predicate, .funs = list(), ..., .by_group = FALSE)

Arguments

.tbl

A tbl object.

.funs

List of function calls generated by funs(), or a character vector of function names, or simply a function.

Bare formulas are passed to rlang::as_function() to create purrr-style lambda functions. Note that these lambda prevent hybrid evaluation from happening and it is thus more efficient to supply functions like mean() directly rather than in a lambda-formula.

...

Additional arguments for the function calls in .funs. These are evaluated only once, with tidy dots support.

.by_group

If TRUE, will sort first by grouping variable. Applies to grouped data frames only.

.vars

A list of columns generated by vars(), a character vector of column names, a numeric vector of column positions, or NULL.

.predicate

A predicate function to be applied to the columns or a logical vector. The variables for which .predicate is or returns TRUE are selected. This argument is passed to rlang::as_function() and thus supports quosure-style lambda functions and strings representing function names.

Examples

1
2
3
4
5
6
7
8
9
df <- as_tibble(mtcars)
df
arrange_all(df)

# You can supply a function that will be applied before taking the
# ordering of the variables. The variables of the sorted tibble
# keep their original values.
arrange_all(df, desc)
arrange_all(df, funs(desc(.)))

olascodgreat/samife documentation built on May 13, 2019, 6:11 p.m.