Learn R Programming

fastplyr (version 0.9.91)

f_arrange: A collapse version of dplyr::arrange()

Description

This is a fast and near-identical alternative to dplyr::arrange() using the collapse package.

desc() is like dplyr::desc() but works faster when called directly on vectors.

Usage

f_arrange(
  .data,
  ...,
  .by = NULL,
  .by_group = FALSE,
  .cols = NULL,
  .descending = FALSE,
  .in_place = FALSE
)

Value

A sorted data.frame.

Arguments

.data

A data frame.

...

Variables to arrange by.

.by

(Optional). A selection of columns to group by for this operation. Columns are specified using tidyselect.

.by_group

If TRUE the sorting will be first done by the group variables.

.cols

(Optional) alternative to ... that accepts a named character vector or numeric vector. If speed is an expensive resource, it is recommended to use this.

.descending

[logical(1)] data frame be arranged in descending order? Default is FALSE. In simple cases this can be easily achieved through desc() but for a mixture of ascending and descending variables, it's easier to use the .descending arg to reverse the order.

.in_place

Should data be sorted in-place? This can be very efficient for large data frames and can be safely used when overwriting a freshly allocated data frame. If you're unsure whether the data frame is a freshly allocated object, use cheapr::semi_copy() before sorting.

Please note that no new vectors and no copies are created, data is directly sorted in-memory. This only works on data frames consisting of atomic vectors.