7.5 Arrange
arrange(flights, year, month, day)
## # A tibble: 336,776 x 19
## year month day dep_time sched_dep_time dep_delay arr_time
## <int> <int> <int> <int> <int> <dbl> <int>
## 1 2013 1 1 517 515 2 830
## 2 2013 1 1 533 529 4 850
## 3 2013 1 1 542 540 2 923
## 4 2013 1 1 544 545 -1 1004
## 5 2013 1 1 554 600 -6 812
## 6 2013 1 1 554 558 -4 740
## 7 2013 1 1 555 600 -5 913
## 8 2013 1 1 557 600 -3 709
## 9 2013 1 1 557 600 -3 838
## 10 2013 1 1 558 600 -2 753
## # ... with 336,766 more rows, and 12 more variables: sched_arr_time <int>,
## # arr_delay <dbl>, carrier <chr>, flight <int>, tailnum <chr>,
## # origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>, hour <dbl>,
## # minute <dbl>, time_hour <dttm>
use desc
to sort things in decending order
arrange(flights, year, month, desc(day))
## # A tibble: 336,776 x 19
## year month day dep_time sched_dep_time dep_delay arr_time
## <int> <int> <int> <int> <int> <dbl> <int>
## 1 2013 1 31 1 2100 181 124
## 2 2013 1 31 4 2359 5 455
## 3 2013 1 31 7 2359 8 453
## 4 2013 1 31 12 2250 82 132
## 5 2013 1 31 26 2154 152 328
## 6 2013 1 31 34 2159 155 135
## 7 2013 1 31 37 2249 108 132
## 8 2013 1 31 54 2250 124 152
## 9 2013 1 31 453 500 -7 651
## 10 2013 1 31 522 525 -3 820
## # ... with 336,766 more rows, and 12 more variables: sched_arr_time <int>,
## # arr_delay <dbl>, carrier <chr>, flight <int>, tailnum <chr>,
## # origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>, hour <dbl>,
## # minute <dbl>, time_hour <dttm>
arrange(flights, year, desc(month), day)
## # A tibble: 336,776 x 19
## year month day dep_time sched_dep_time dep_delay arr_time
## <int> <int> <int> <int> <int> <dbl> <int>
## 1 2013 12 1 13 2359 14 446
## 2 2013 12 1 17 2359 18 443
## 3 2013 12 1 453 500 -7 636
## 4 2013 12 1 520 515 5 749
## 5 2013 12 1 536 540 -4 845
## 6 2013 12 1 540 550 -10 1005
## 7 2013 12 1 541 545 -4 734
## 8 2013 12 1 546 545 1 826
## 9 2013 12 1 549 600 -11 648
## 10 2013 12 1 550 600 -10 825
## # ... with 336,766 more rows, and 12 more variables: sched_arr_time <int>,
## # arr_delay <dbl>, carrier <chr>, flight <int>, tailnum <chr>,
## # origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>, hour <dbl>,
## # minute <dbl>, time_hour <dttm>