df.sort: Data Frame Sorting

View source: R/df.sort.R

df.sortR Documentation

Data Frame Sorting

Description

This function arranges a data frame in increasing or decreasing order according to one or more variables.

Usage

df.sort(x, ..., decreasing = FALSE, check = TRUE)

Arguments

x

a data frame.

...

a sorting variable or a sequence of sorting variables which are specified without quotes '' or double quotes "".

decreasing

logical: if TRUE, the sort is decreasing.

check

logical: if TRUE (default), argument specification is checked.

Value

Returns data frame x sorted according to the variables specified in ..., a matrix will be coerced to a data frame.

Author(s)

Takuya Yanagida takuya.yanagida@univie.ac.at

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.

Knuth, D. E. (1998) The Art of Computer Programming, Volume 3: Sorting and Searching (2nd ed.). Addison-Wesley.

See Also

df.duplicated, df.merge, df.move, df.rbind, df.rename, df.subset

Examples

dat <- data.frame(x = c(5, 2, 5, 5, 7, 2),
                  y = c(1, 6, 2, 3, 2, 3),
                  z = c(2, 1, 6, 3, 7, 4))

# Example 1: Sort data frame 'dat' by "x" in increasing order
df.sort(dat, x)

# Example 2: Sort data frame 'dat' by "x" in decreasing order
df.sort(dat, x, decreasing = TRUE)

# Example 3: Sort data frame 'dat' by "x" and "y" in increasing order
df.sort(dat, x, y)

# Example 4: Sort data frame 'dat' by "x" and "y" in decreasing order
df.sort(dat, x, y, decreasing = TRUE)

misty documentation built on Oct. 24, 2024, 5:10 p.m.

Related to df.sort in misty...