sort | R Documentation |
Sorts a data frame by one or more columns.
## S3 method for class 'data.frame'
sort(x, decreasing = FALSE, by, ...)
x |
Data frame. |
decreasing |
Logical value specifying whether to sort by decreasing order. |
by |
Field variable names or column indices by which to sort a data frame. |
... |
Not used. |
order
# Create a simple data frame:
x <- data.frame(
u = c(1, 1, 1, 1, 2, 2, 2, 3),
v = c(1, 2, 3, 4, 1, 2, 3, 3))
sort(x, by = "u")
sort(x, by = "v")
sort(x, by = c("u", "v")) # Sort by both variables.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.