relocate.: Relocate a column to a new position

Description Usage Arguments Examples

View source: R/relocate.R

Description

Move a column or columns to a new position

Usage

1
relocate.(.df, ..., .before = NULL, .after = NULL)

Arguments

.df

A data.frame or data.table

...

A selection of columns to move. tidyselect compatible.

.before

Column to move selection before

.after

Column to move selection after

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
test_df <- data.table(
  a = 1:3,
  b = 1:3,
  c = c("a", "a", "b"),
  d = c("a", "a", "b")
)

test_df %>%
  relocate.(c, .before = b)

test_df %>%
  relocate.(a, b, .after = c)

test_df %>%
  relocate.(where(is.numeric), .after = c)

mtfairbanks/gdt documentation built on May 4, 2021, 9:44 a.m.