sort: Sort Data Frame

sortR Documentation

Sort Data Frame

Description

Sorts a data frame by one or more columns.

Usage

## S3 method for class 'data.frame'
sort(x, decreasing = FALSE, by, ...)

Arguments

x

Data frame.

decreasing

Logical value specifying whether to sort by decreasing order.

by

Field variable names or column indices by which to sort a data frame.

...

Not used.

See Also

order

Examples

# Create a simple data frame:
x <- data.frame(
        u = c(1, 1, 1, 1, 2, 2, 2, 3),
        v = c(1, 2, 3, 4, 1, 2, 3, 3))

sort(x, by = "u")
sort(x, by = "v")
sort(x, by = c("u", "v"))  # Sort by both variables.


TobieSurette/gulf.utils documentation built on Dec. 1, 2024, 6:01 a.m.