data_relocate: Relocate (reorder) columns of a data frame

Description Usage Arguments Value Examples

View source: R/data_relocate.R

Description

Relocate (reorder) columns of a data frame

Usage

1
data_relocate(data, cols, before = NULL, after = NULL, safe = TRUE, ...)

Arguments

data

A data frame to pivot.

cols

A character vector indicating the names of the columns to move.

before, after

Destination of columns. Supplying neither will move columns to the left-hand side; specifying both is an error.

safe

If TRUE, will disregard non-existing columns.

...

Other arguments passed to or from other functions.

Value

A data frame with reordered columns.

Examples

1
2
3
4
5
# Reorder columns
head(data_relocate(iris, cols = "Species", before = "Sepal.Length"))
head(data_relocate(iris, cols = "Species", before = "Sepal.Width"))
head(data_relocate(iris, cols = "Sepal.Width", after = "Species"))
head(data_relocate(iris, cols = c("Species", "Petal.Length"), after = "Sepal.Width"))

datawizard documentation built on Oct. 4, 2021, 9:07 a.m.