sort {miscset} | R Documentation |
Sort data.frame Objects
Description
Sort a data.frame by any column(s).
Usage
## S3 method for class 'data.frame'
sort(x, decreasing = FALSE, by = NULL, bye = NULL,
na.last = NA, ...)
Arguments
x |
A data.frame. |
decreasing |
Logical, sort in decreasing order. See also sort. |
by |
Index (integer) or names of columns in |
bye |
Unquoted column name or |
na.last |
|
... |
Ignored for the data.frame method. |
Author(s)
Sven E. Templer
Examples
#
d <- data.frame(a=c(1,1,1,2,NA),b=c(2,1,3,1,1),c=5:1)
d
sort(d) # sort by every column (a, then b, then c)
sort(d, TRUE, by="c") # decreasing by column 'c'
sort(d, bye=.(a,c)) # increasing by columns 'a' and then 'c'
#
[Package miscset version 1.1.0 Index]