df.sort | R Documentation |
This function arranges a data frame in increasing or decreasing order according to one or more variables.
df.sort(data, ..., decreasing = FALSE, check = TRUE)
data |
a data frame. |
... |
a sorting variable or a sequence of sorting variables which are specified without
quotes |
decreasing |
logical: if |
check |
logical: if |
Returns data frame data
sorted according to the variables specified in ...
,
a matrix will be coerced to a data frame.
Takuya Yanagida takuya.yanagida@univie.ac.at
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.
df.duplicated
, df.merge
,
df.move
, df.rbind
,
df.rename
,
df.subset
# Example 1: Sort data frame 'mtcars' by 'mpg' in increasing order
df.sort(mtcars, mpg)
# Example 2: Sort data frame 'mtcars' by 'mpg' in decreasing order
df.sort(mtcars, mpg, decreasing = TRUE)
# Example 3: Sort data frame 'mtcars' by 'mpg' and 'cyl' in increasing order
df.sort(mtcars, mpg, cyl)
# Example 4: Sort data frame 'mtcars' by 'mpg' and 'cyl' in decreasing order
df.sort(mtcars, mpg, cyl, decreasing = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.