changeColName: changeColName()

Description Usage Arguments Details Examples

Description

Changes a column name. Accepts both data frame and data.table inputs. Multiple column names can be changed with the simple syntax old_column_name/new_column_name.

Usage

1
2
3

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
5
Here is how to change a column name, where we change a column named "Jake"
into one named "Josh":

\code{changeColName(my_data, "Jake", "Josh")}
\code{changeColName(my_data, Jake/Josh, ref = FALSE, warnings = FALSE)}

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