sort_by: Sort by

Description Usage Arguments Value Examples

View source: R/sort-by.R

Description

Sort an object by another object

Usage

1
sort_by(x, by, ...)

Arguments

x

A vector

by

Another vector

...

Additional arguments passed to base::order()

Value

The values of x, resorted

Examples

1
2
3
4
5
6
l3 <- letters[1:3]
sort_by(l3, c(3, 2, 1))
# make a factor object with the reversed order
f <- factor(l3, levels = rev(l3))
sort_by(f, l3)
sort_by(1:3, rev(l3))

mark documentation built on July 16, 2021, 9:07 a.m.