Arrange a data frame and rank indexes.
add_rank_indices(.data, ..., arrangeTerms = NULL, orderColumn)
.data | data.frame |
---|---|
... | force later arguments to bind by name. |
arrangeTerms | character vector of column expressions to arrange by. |
orderColumn | character name of column to add in-group order marks to. |
.data with order indices added (no ties).
datasets::mtcars %.>% # tibble::rownames_to_column() not currently re-exported by dplyr mutate_se(., "CarName" := "rownames(.)" ) %.>% select_se(., c('CarName', 'hp', 'wt')) %.>% add_rank_indices(., arrangeTerms = c('desc(hp)', 'wt'), orderColumn = 'rankID') %.>% arrange_se(., 'rankID')#> CarName hp wt rankID #> Maserati Bora Maserati Bora 335 3.570 1 #> Ford Pantera L Ford Pantera L 264 3.170 2 #> Duster 360 Duster 360 245 3.570 3 #> Camaro Z28 Camaro Z28 245 3.840 4 #> Chrysler Imperial Chrysler Imperial 230 5.345 5 #> Lincoln Continental Lincoln Continental 215 5.424 6 #> Cadillac Fleetwood Cadillac Fleetwood 205 5.250 7 #> Merc 450SL Merc 450SL 180 3.730 8 #> Merc 450SLC Merc 450SLC 180 3.780 9 #> Merc 450SE Merc 450SE 180 4.070 10 #> Ferrari Dino Ferrari Dino 175 2.770 11 #> Hornet Sportabout Hornet Sportabout 175 3.440 12 #> Pontiac Firebird Pontiac Firebird 175 3.845 13 #> AMC Javelin AMC Javelin 150 3.435 14 #> Dodge Challenger Dodge Challenger 150 3.520 15 #> Merc 280 Merc 280 123 3.440 16 #> Merc 280C Merc 280C 123 3.440 17 #> Lotus Europa Lotus Europa 113 1.513 18 #> Mazda RX4 Mazda RX4 110 2.620 19 #> Mazda RX4 Wag Mazda RX4 Wag 110 2.875 20 #> Hornet 4 Drive Hornet 4 Drive 110 3.215 21 #> Volvo 142E Volvo 142E 109 2.780 22 #> Valiant Valiant 105 3.460 23 #> Toyota Corona Toyota Corona 97 2.465 24 #> Merc 230 Merc 230 95 3.150 25 #> Datsun 710 Datsun 710 93 2.320 26 #> Porsche 914-2 Porsche 914-2 91 2.140 27 #> Fiat X1-9 Fiat X1-9 66 1.935 28 #> Fiat 128 Fiat 128 66 2.200 29 #> Toyota Corolla Toyota Corolla 65 1.835 30 #> Merc 240D Merc 240D 62 3.190 31 #> Honda Civic Honda Civic 52 1.615 32