sortdf: Order the rows of a data frame

sortdfR Documentation

Order the rows of a data frame

Description

Order the rows of a data frame using variables identified in a formula evaluated in the data frame. Convenient in a pipeline.

Usage

sortdf(data, form = formula(data))

Arguments

data

a data frame

form

a variable, list of variables, or a formula identifying variables to be used in sorting or an object that can be used directly in data[order(form,,drop=FALSE)].

Value

The formula is evaluated using model.frame and the result is used as the argument of order which, in turn is used to order the data frame. The ordered data frame is returned.

Examples

## Not run: 
require(car)
require(magrittr)
Prestige  %>% sortdf(~type+income) -> Prestige.ordered

## End(Not run)

gmonette/spida2 documentation built on Aug. 11, 2024, 7:52 p.m.