move.df.col: Function to change easily the order of specific columns in a...

move.df.colR Documentation

Function to change easily the order of specific columns in a data.frame.

Description

Allows to change the position of a column in a data.frame using other columns as reference.

Usage

move.df.col(data.frame, move.command)

Arguments

data.frame

An input data.frame.

move.command

A string containing the moving command. The command is formed as follows: "columnA movingCommand columnB". The basic options are: "first", "last", "before", "after". Compounded moves must be separated by a semicolon. Example: "g first; a last; e before c".

Value

It returns the original data.frame but with the columns moved as demanded.

References

https://stackoverflow.com/questions/3369959/moving-columns-within-a-data-frame-without-retyping

Examples

new.mtcars = move.df.col(mtcars, "mpg last")

new.mtcars = move.df.col(mtcars, "wt before carb")

new.mtcars = move.df.col(mtcars, "am before carb; cyl first")


sebastian-gregoricchio/Rseb documentation built on May 15, 2024, 5:45 a.m.