swap_cols: Swap columns in a data frame

Description Usage Arguments Value Examples

View source: R/asymmetrise.R

Description

Swap columns .x and .y in df.

Usage

1
swap_cols(df, .x, .y)

Arguments

df

a data.frame (or tibble) object

.x, .y

column names to switch

Value

a data.frame (or tibble) object with .x and .y swapped

Examples

1
2
3
4
5
6
7
8
df <- data.frame(
  a = c("A", "B"),
  b = c("C", "D"),
  untouched = c(1, 2)
)
df

swap_cols(df, a, b)

Example output

  a b untouched
1 A C         1
2 B D         2
# A tibble: 2 x 3
  a     b     untouched
  <chr> <chr>     <dbl>
1 C     A             1
2 D     B             2

ggasym documentation built on May 16, 2021, 1:07 a.m.