arrange_se: Arrange standard interface.

Description Usage Arguments Value See Also Examples

View source: R/arrange_se.R

Description

Arrange a data frame by the possibly the group_vars() (optional, but defaults to off) and arrangeTerms. Accepts arbitrary text as arrangeTerms to allow forms such as "desc(gear)". Intent is to arrange only by sets of variables with desc() notations reversals, not by arbitrary expressions over variables. To help enforce this parsing is performed in an empty environment (so expressions such as "gear + carb" deliberately error-out).

Usage

1
arrange_se(.data, arrangeTerms, ..., .by_group = FALSE, strict = TRUE)

Arguments

.data

data.frame

arrangeTerms

character vector of column expressions to arrange by.

...

not used, force later arguments to bind by name.

.by_group

logical, should data be sorted by grouping variables (if present).

strict

logical if TRUE accept only name and desc(name) terms.

Value

.data arrnaged by arrangeTerms

See Also

arrange, arrange_at

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
datasets::mtcars %.>%
  arrange_se(., c("cyl", "desc(gear)")) %.>%
  head(.)
# equivilent to dplyr/magrittr pipeline
# arrange(datasets::mtcars, cyl, desc(gear)) %>% head()

# Note: arranging in the presence of groups is subtle.
# As grouping is an annotation, not an ordering (and ordering is
# unfortunately not an annotation).

d <- data.frame(x = 1:6,
                sin_x = sin(1:6),
                grp = rep(c("a", "b"), 3),
                stringsAsFactors = FALSE)

# arranged by sin_x and not by grp
d %.>%
  group_by_se(., "grp") %.>%
  arrange_se(., "sin_x")

# arranged by sin_x and not by grp
d %.>%
  arrange_se(., "sin_x") %.>%
  group_by_se(., "grp")

# arranged by sin_x and not by grp
d %.>%
  group_by_se(., "grp") %.>%
  arrange_se(., "sin_x", .by_group = TRUE)

# arranged by sin_x and not by grp
d %.>%
  arrange_se(., "sin_x", .by_group = TRUE) %.>%
  group_by_se(., "grp")

seplyr documentation built on June 12, 2021, 5:07 p.m.