Description Usage Arguments Details Value Author(s) Examples
Sort rows of an data.frame
by values in specified columns.
1 2 3 4 5 6 7 | sortByCol(
data.frame,
columns,
na.last = TRUE,
decreasing = TRUE,
orderAsAttr = FALSE
)
|
data.frame |
A |
columns |
Column name(s) which sould be ordered |
na.last |
Logical, whether NA should be sorted as last |
decreasing |
Logical, whether the sorting should be in the decreasing order |
orderAsAttr |
Logical, whether the order index vectors should be
returned in the attribute “order” of the sorted |
Columns can be specified by integer indices, logical vectors or character names.
Sorted data.frame
Jitao David Zhang <jitao_david.zhang@roche.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 | sample.df <- data.frame(teams=c("HSV", "BVB", "FCB", "FCN"),pts=c(18,17,17,9), number=c(7,7,6,6))
sortByCol(sample.df, 1L)
sortByCol(sample.df, 1L, decreasing=FALSE)
sortByCol(sample.df, c(3L, 1L))
sortByCol(sample.df, c(3L, 1L), decreasing=FALSE)
sortByCol(sample.df, c(3L, 2L))
sortByCol(sample.df, c(TRUE, FALSE, TRUE))
sortByCol(sample.df, c("teams", "pts"))
sortByCol(sample.df, c("pts", "number", "teams"))
sortByCol(sample.df, c("pts", "teams", "number"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.