sort_asc: Sort data.frames/matrices/vectors

Description Usage Arguments Value Examples

Description

sort_asc sorts in ascending order and sort_desc sorts in descending order. .sort_asc/.sort_desc are versions for working with default_dataset.

Usage

1
2
3
4
5
6
7
sort_asc(data, ..., na.last = FALSE)

.sort_asc(..., na.last = FALSE)

sort_desc(data, ..., na.last = TRUE)

.sort_desc(..., na.last = TRUE)

Arguments

data

data.frame/matrix/vector

...

character/numeric or criteria/logical functions (see criteria). Column names/numbers for data.frame/matrix by which object will be sorted. Names at the top-level can be unquoted (non-standard evaluation). For standard evaluation of parameters you can surround them by round brackets. See examples. Ignored for vectors.

na.last

for controlling the treatment of NAs. If TRUE, missing values in the data are put last; if FALSE, they are put first; if NA, they are removed.

Value

sorted data

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
data(mtcars)
sort_asc(mtcars, mpg)
sort_asc(mtcars, cyl, mpg) # by two column

# same results with column nums
sort_asc(mtcars, 1)
sort_asc(mtcars, 2:1) # by two column
sort_asc(mtcars, 2, 1) # by two column

# call with parameter
sorting_columns = c("cyl", "mpg")
sort_asc(mtcars, (sorting_columns)) 

gdemin/expss documentation built on May 16, 2019, 11:14 p.m.