Relocate columns
Usage
relocate_with(
.data,
.fn,
.cols = everything(),
.before = NULL,
.after = NULL,
...
)
Arguments
- .data
A
data.frame
ortibble
.- .fn
A function to reorder
.cols
.- .cols
Columns to move
- .before, .after
Destination of columns. If both selected, errors. If neither, moves to right of first selected column.
- ...
additional arguments to pass to
.fn
Examples
data(sd)
sd |> relocate_with(sort)
#> # A tibble: 1 × 38
#> adv_16 adv_18 adv_20 arv_16 arv_18 arv_20 atg_18…¹ atg_1…² cd_2020 gov_1…³
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int> <dbl>
#> 1 109961. 138961. NA 244809. 186191. NA 144576. 177592. 1 160427.
#> # … with 28 more variables: gov_18_rep_noe <dbl>, ndv <dbl>, nrv <dbl>,
#> # pop <dbl>, pop_aian <dbl>, pop_asian <dbl>, pop_black <dbl>,
#> # pop_hisp <dbl>, pop_nhpi <dbl>, pop_other <dbl>, pop_two <dbl>,
#> # pop_white <dbl>, pre_16_dem_cli <dbl>, pre_16_rep_tru <dbl>,
#> # sos_18_dem_fre <dbl>, sos_18_rep_bar <dbl>, state <chr>,
#> # uss_16_dem_wil <dbl>, uss_16_rep_thu <dbl>, vap <dbl>, vap_aian <dbl>,
#> # vap_asian <dbl>, vap_black <dbl>, vap_hisp <dbl>, vap_nhpi <dbl>, …
#> # ℹ Use `colnames()` to see all variable names