Swap columns .x
and .y
in df
.
swap_cols(df, .x, .y)
df | a data.frame (or tibble) object |
---|---|
.x, .y | column names to switch |
a data.frame (or tibble) object with .x
and .y
swapped
#> a b untouched #> 1 A C 1 #> 2 B D 2swap_cols(df, a, b)#> # A tibble: 2 x 3 #> a b untouched #> <chr> <chr> <dbl> #> 1 C A 1 #> 2 D B 2