Arrange rows via descending or ascending column values
arrange_data(.data, ...)
.data | data frame |
---|---|
... | One or more unquoted names of columns on which to arrange the rows. If none
are supplied, the data are returned as is. By default, ordering is done in ascending
order. To orer in descending order, use |
Rearranged data frame
## data frame to arrange dat <- data.frame( a = c(rep("a", 3), rep("b", 3), rep("c", 4)), b = c( 3, 3, 2, 8, 8, 1, 5, 5, 5, 9), c = c(-1, 0, 0, -5, 0, 2, -2, -4, 1, 0), stringsAsFactors = FALSE ) ## arrange by one column arrange_data(dat, a)#> a b c #> 1 a 3 -1 #> 2 a 3 0 #> 3 a 2 0 #> 4 b 8 -5 #> 5 b 8 0 #> 6 b 1 2 #> 7 c 5 -2 #> 8 c 5 -4 #> 9 c 5 1 #> 10 c 9 0#> a b c #> 1 c 5 -4 #> 2 c 5 -2 #> 3 c 5 1 #> 4 c 9 0 #> 5 b 1 2 #> 6 b 8 -5 #> 7 b 8 0 #> 8 a 2 0 #> 9 a 3 -1 #> 10 a 3 0