df_arrange: Arrange Rows by Column Values

View source: R/df.R

df_arrangeR Documentation

Arrange Rows by Column Values

Description

Order the rows of a data frame by values of specified columns. Wrapper arround the arrange() function. Supports standard and non standard evaluation.

Usage

df_arrange(data, ..., vars = NULL, .by_group = FALSE)

Arguments

data

a data frame

...

One or more unquoted expressions (or variable names) separated by commas. Used to select a variable of interest. Use desc() to sort a variable in descending order.

vars

a character vector containing the variable names of interest.

.by_group

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

Value

a data frame

Examples

df <- head(ToothGrowth)
df

# Select column using standard evaluation
df %>% df_arrange(vars = c("dose", "len"))

# Select column using non-standard evaluation
df %>% df_arrange(dose, desc(len))

kassambara/rstatix documentation built on Feb. 6, 2023, 3:36 a.m.