View source: R/sortDataframe.R
sortDataframe | R Documentation |
Sort data.frame according to multiple columns.
sortDataframe(x, by = x, decreasing = FALSE, returnID = FALSE)
x |
a data.frame to sort. |
by |
either a data.frame, or a vector of characters, or a vector of integers. The data.frame x is sorted according to this parameter. If it is a data.frame, then the column names should be a part of column names of x. A vector of characters must not exceed the column names of x. The integer vector is the index of columns. |
decreasing |
logic. Should the sort order be increasing (default) or decreasing? |
returnID |
logic. If FALSE (default), the sorted index is not returned. |
A sorted data.frame according to 'by'.
## Not run:
x = data.frame(a = c(3,3,6,4,4), b = c(4,2,2,1,1), c = 1:5)
sortDataframe(x)
sortDataframe(x, by = c("a", "b"))
sortDataframe(x, by = 1:2)
sortDataframe(x, by = x[, 1:2])
sortDataframe(x, returnID = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.