changeColOrder: changeColOrder()

Description Usage Arguments Details Examples

Description

Changes the order of columns by placing a specified column to the left of another specified column.

Usage

1

Arguments

data

a data.frame or data.table

...

either a) if you are only changing one column, the current column name, followed by a comma and then the desired column name (option of NSE), or b) one or more of the following: current_column_name/desired_column_name, where the current column name is followed by a forward slash followed by your desired column name. Using the function in this way, you may change as many column names as you like in one function call.

ref

TRUE (default) or FALSE, if TRUE and data is a data.table, modify the data.table by reference (modifying-in-place), if FALSE, do not modify the data.table by reference, instead treat it like a data.frame (copy on modify).

warnings

TRUE (default) or FALSE, should warnings occur when modifications by reference occur or conversions take place?

Details

This function uses seperate methods for data.tables and data.frames. By default, data.tables will be modified by reference. To turn off this behavior, set ref to FALSE.

Examples

1
2
3
4
Here is how to change a column name, where we change a column named "Jake"
into one named "Josh":

\code{changeColOrder(my_data, "Jake", "Josh")}

jakesherman/jakemisc documentation built on May 18, 2019, 9:08 a.m.