Skip to contents

Sort a Data Frame by all of its Columns

Usage

fullySorted(x, decreasing = FALSE, ..., renumber.rows = TRUE)

Arguments

x

data frame

decreasing

passed to order

...

further arguments passed to order

renumber.rows

if TRUE (default) the rows in the returned data frame are renumbered from 1 to the number of rows in x

Examples

fullySorted(head(iris))
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1          4.6         3.1          1.5         0.2  setosa
#> 2          4.7         3.2          1.3         0.2  setosa
#> 3          4.9         3.0          1.4         0.2  setosa
#> 4          5.0         3.6          1.4         0.2  setosa
#> 5          5.1         3.5          1.4         0.2  setosa
#> 6          5.4         3.9          1.7         0.4  setosa
fullySorted(head(iris), decreasing = TRUE)
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1          5.4         3.9          1.7         0.4  setosa
#> 2          5.1         3.5          1.4         0.2  setosa
#> 3          5.0         3.6          1.4         0.2  setosa
#> 4          4.9         3.0          1.4         0.2  setosa
#> 5          4.7         3.2          1.3         0.2  setosa
#> 6          4.6         3.1          1.5         0.2  setosa
fullySorted(head(iris[, 5:1]))
#>   Species Petal.Width Petal.Length Sepal.Width Sepal.Length
#> 1  setosa         0.2          1.3         3.2          4.7
#> 2  setosa         0.2          1.4         3.0          4.9
#> 3  setosa         0.2          1.4         3.5          5.1
#> 4  setosa         0.2          1.4         3.6          5.0
#> 5  setosa         0.2          1.5         3.1          4.6
#> 6  setosa         0.4          1.7         3.9          5.4
fullySorted(head(iris[, 5:1]), decreasing = TRUE)
#>   Species Petal.Width Petal.Length Sepal.Width Sepal.Length
#> 1  setosa         0.4          1.7         3.9          5.4
#> 2  setosa         0.2          1.5         3.1          4.6
#> 3  setosa         0.2          1.4         3.6          5.0
#> 4  setosa         0.2          1.4         3.5          5.1
#> 5  setosa         0.2          1.4         3.0          4.9
#> 6  setosa         0.2          1.3         3.2          4.7