Learn R Programming

rstatix (version 0.7.2)

df_arrange: 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)

Value

a data frame

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.

Examples

Run this code
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))

Run the code above in your browser using DataLab