reorder: Data Reordering

Description Usage Arguments Details Value See Also Examples

Description

Reorder the rows in a dataset.

Usage

1
2
## S3 method for class 'dataset'
reorder(x, ...)

Arguments

x

a dataset object.

...

a sequence of expressions that evaluate to vector-like or matrix-like values with the same number of rows as x.

Details

reorder reorders the rows of x according to the specified expressions. These expressions get evaluated via the scope function in a context that looks for symbols in x before the calling environment. After the arguments get evaluated the arguments get converted to numeric via xtfrm.dataset, and then the rows of x get sorted using these values.

By default, we sort in ascending order according to the arguments, in order. To use descending order for one or more of the arguments use desc = before the argument; see the examples below. You can also specify asc =, but this has no effect as ascending order is the default.

Value

A dataset with the rows of x put in the specified order.

See Also

order.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
x <- as.dataset(mtcars)

# order by 'cyl'
reorder(x, cyl)

# break ties using 'gear'
reorder(x, cyl, gear)

# order by 'cyl' descending, 'gear' ascending
reorder(x, desc = cyl, gear)

# order by 'cyl' descending, 'gear' descending
reorder(x, desc = cyl, desc = gear)

patperry/r-frame documentation built on May 6, 2019, 8:34 p.m.