Learn R Programming

datawizard (version 0.6.0)

data_arrange: Arrange rows by column values

Description

data_arrange() orders the rows of a data frame by the values of selected columns.

Usage

data_arrange(data, select = NULL, safe = TRUE)

Value

A data frame.

Arguments

data

A data frame, or an object that can be coerced to a data frame.

select

Character vector of column names. Use a dash just before column name to arrange in decreasing order, for example "-x1".

safe

Do not throw an error if one of the variables specified doesn't exist.

Examples

Run this code
if (FALSE) {
# Arrange using several variables
data_arrange(head(mtcars), "gear", "carb")

# Arrange in decreasing order
data_arrange(head(mtcars), "-carb")

# Throw an error if one of the variables specified doesn't exist
data_arrange(head(mtcars), "gear", "foo", safe = FALSE)
}

Run the code above in your browser using DataLab