Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

reorder_columns

Reordering Columns


Description

Reorders columns according to a prefered target order

Usage

reorder_columns(x, target, decreasing = FALSE)

Arguments

x

an object with columns, such as a matrix or a data.frame, or from a class that support subsetting via x[, i, drop = FALSE] and has a method colnames.

target

a character or named numeric vector that specifies the column prefered order. If a numeric vector, then its names are assumed to correspond to columns, and its values determine the target order – according to argument decreasing.

decreasing

logical that indicates in which direction a numeric target vector should be ordered.

Details

Column names will be reordered so that their order match the one in target. Any column that does not appear in target will be put after those that are listed in target.

Value

an object of the same type and dimension


pkgmaker

Development Utilities for R Packages

v0.32.2
GPL (>= 2)
Authors
Renaud Gaujoux [aut, cre]
Initial release
2020-10-20

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.