Description Usage Arguments Details Examples
Changes the class of columns from one class to another class, ex. change all
columns of class factor into columns of class character. Works on both
data.frame
and data.table
classes. You may also specify either
a) specific columns to do this conversion on, or alternatively b) specific
columns that you do not want conversion performed on.
1 2 |
data |
a |
startingClass |
the column type you want converted |
finalClass |
the column type you want to convert startingClass into |
onlyConvert |
OPTIONAL - specify a vector of one or more column names as the only columns where the class conversion will take place. You may either have this parameter satified, or the noConvert parameter specified, you may not specify both. |
noConvert |
OPTIONAL - specify a vector of one or more columns names that you do not want any conversion applied to. You may either have this parameter satified, or the noConvert parameter specified, you may not specify both. |
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). |
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
.
1 2 3 4 5 | \code{changeColClass(my_data, "factor", "character")}
\code{changeColClass(my_data, "numeric", "character",
onlyConvert = c(my_cols))}
\code{changeColClass(my_data, "numeric", "character",
noConvert = "special_col")}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.