Arrange rows by variables.

Use desc to sort a variable in descending order.

arrange(.data, ...)

arrange_(.data, ..., .dots)

A tbl. All main verbs are S3 generics and provide methods for tbl_df, tbl_dt and tbl_sql.
Comma separated list of unquoted variable names. Use desc to sort a variable in descending order.
Used to work around non-standard evaluation. See vignette("nse") for details.

An object of the same class as .data.

Data frame row names are silently dropped. To preserve, convert to an explicit variable.


Note that for local data frames, the ordering is done in C++ code which does not have access to the local specific ordering usually done in R. This means that strings are ordered as if in the C locale.

See Also

Other single.table.verbs: filter, filter_; mutate, mutate_, transmute, transmute_; rename, rename_, select, select_; slice, slice_; summarise, summarise_, summarize, summarize_

  • arrange
  • arrange_
arrange(mtcars, cyl, disp)
arrange(mtcars, desc(disp))
Documentation reproduced from package dplyr, version 0.3, License: MIT + file LICENSE

Community examples at Jan 24, 2018 dplyr v0.7.3

``` title <- c('Effective Java','Orientalism','False Impressions','How To Program Java','Making Software') height <- c('123','197','177','238','245') year <- c('2011','2011','3015','1999','1997') books <- data.frame(title, height, year) ##order by the column "title" orderedBooks <- arrange(books, title) ##order by the column "title, year" orderedBooks <- arrange(books, title, year) ##order by the columns "title" in assending: orderedBooks <- arrange(books, desc(title)) ``` [more examples](

filipsch at Feb 21, 2017 dplyr v0.5.0

```r library(dplyr) mtcars %>% arrange(hp) ```