Description Usage Arguments Details Value Functions Examples
The functions ClassMorph
, and NumMorph
, in addition to
DateMorph
, are functions designed to make dealing with column classes
easy. See examples for how to avoid uncessary frustrations related to
unexpected column classes or date formats.
1 2 3 4 5 6 7 |
DT |
A data.table to use for any "class" operations |
old |
ClassMorph only. A column type, specified as a character value, to detect and convert to the class specified by 'new' |
new |
ClassMorph only. A column type, specified as a character value, to convert all columns of the class specified by 'old' to. |
copy |
A boolean value indicating whether to alter |
force |
A boolean indicating whether to force conversion from class factor to class numeric despite NAs being generated. |
cols |
An optional character vector of column names to operate on. Not applicable for function ClassMorph. |
verbose |
A boolean indicating whether to be chatty |
ord |
For convenience, an optional char vec indicating how to sort rows. Can be one of: "CName", "Class", or "Pos" (position) |
bret |
A boolean indicating whether to return the data.table (rather than print by default) |
This function takes care of multiple conversion steps that are sometimes
needed to avoid data loss or unexpected results (e.g. a factor that "looks"
like the number "1" may not convert to a numeric
"1". To get around
this common frustration, this function will perform an indirect conversion to
character
before converting to numeric
)
Returns a data.table that is either a copy of the input DT that has been modified, or the same input DT that has been modified in memory
ClassMorph
: A function to convert all columns of class "old" to class "new". This
function handles the indirect conversions sometimes needed to avoid data loss or
unexpected results (see details).
NumMorph
: A function to standards classes to "numeric" for all columns of
DT, where a conversion to numeric would not generate NA values.
pcc
: prints (default) or returns a data.table describing column classes
1 2 3 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.