sort_vars: Sort data by variables

View source: R/sort_vars.R

sort_varsR Documentation

Sort data by variables

Description

Sorts a dataframe by one or more variables, and returns the result along with tidyverse code used to generate it.

Usage

sort_vars(data, vars, asc = rep(TRUE, length(vars)))

Arguments

data

a dataframe to sort

vars

a character vector of variable names to sort by

asc

logical, length of 1 or same length as vars. If TRUE (default), then sorted in ascending order, otherwise descending.

Value

data with tidyverse code attached

Author(s)

Owen Jin, Zhaoming Su

See Also

code

Examples

sorted <- sort_vars(iris,
    vars = c("Sepal.Width", "Sepal.Length"),
    asc = c(TRUE, FALSE)
)
cat(code(sorted))
head(sorted)


iNZightTools documentation built on Oct. 12, 2023, 5:06 p.m.