dfOrder: Sort (order) a dataframe or matrix by multiple columns

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Although order will order a vector, and it is possible to order several columns of a data.frame by specifying each column individually in the call to order, dfOrder will order a dataframe by as many columns as desired.

Usage

1
dfOrder(object, columns)

Arguments

object

The data.frame to be sorted

columns

Column numbers to use for sorting. If positive, then they will be sorted in increasing order. If negative, then in decreasing order

Details

This is just a simple helper function to reorder data.frames. Developed to organize IRT output from the ltm package. It is a basic add on to the order function.

Value

The original data frame is now in sorted order.

Author(s)

William Revelle

See Also

This code is used in the test.irt function to combine ltm and sim.irt output.

Examples

1
2
3
x <- data.frame(matrix(sample(1:4,50,replace=TRUE),ncol=5))
dfOrder(x,c(1,4))
dfOrder(x,c(1,-2))

frenchja/psych documentation built on May 16, 2019, 2:49 p.m.