relocate: Relocate a column to a new position

View source: R/relocate.R

relocateR Documentation

Relocate a column to a new position

Description

Move a column or columns to a new position

Usage

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

df <- data.table(
  a = 1:3,
  b = 1:3,
  c = c("a", "a", "b"),
  d = c("a", "a", "b")
)

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

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

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

tidytable documentation built on Sept. 11, 2024, 8:05 p.m.