Debian Codegraph @

man/sort-methods.Rd

raw
1 \name{sort-methods}
2 \alias{sort.data.frame}
3 \alias{sort.data.set}
4 \title{Convenience Methods to Sort Data Frames and Data Sets}
5 \description{
6 The methods below return a sorted version of
7 the data frame or data set, given as first argument.
8 }
9 \usage{
10 \method{sort}{data.frame}(x,decreasing=FALSE,by=NULL,na.last=NA,\dots)
11 \method{sort}{data.set}(x,decreasing=FALSE,by=NULL,na.last=NA,\dots)
12 }
13 \arguments{
14 \item{x}{a data frame or data set.}
15 \item{decreasing}{a logical value, should sorting
16 be in increasing or decreasing order?}
17 \item{by}{
18 a character name of variable names, by which to sort;
19 a formula giving the variables, by which to sort;
20 NULL, in which case, the data frame / data set
21 is sorted by all of its variables.
22 }
23 \item{na.last}{for controlling the treatment of 'NA's. If 'TRUE', missing
24 values in the data are put last; if 'FALSE', they are put
25 first; if 'NA', they are removed}
26 \item{\dots}{other arguments, currently ignored.}
27 }
28 \value{
29 A sorted copy of \code{x}.
30 }
31 \examples{
32 DF <- data.frame(
33 a = sample(1:2,size=20,replace=TRUE),
34 b = sample(1:4,size=20,replace=TRUE))
35 sort(DF)
36 sort(DF,by=~a+b)
37 sort(DF,by=~b+a)
38 sort(DF,by=c("b","a"))
39 sort(DF,by=c("a","b"))
40 }