Description Usage Arguments Details Author(s) See Also Examples
View source: R/convert_datatable_FactorString.R
Shortcut to convert data.table columns from factor to string.
1 | convert_datatable_FactorString(dat, cols = NULL)
|
dat |
A data.table |
cols |
(optional) A vector of column names or column numbers to be converted. If blank, then all columns of class character are converted. |
Returns the data.table invisibly because data.tables are modified in place, and there is no need to make a copy.
Gene Leynes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | require(geneorama)
## Create examples
dt <- as.data.table(OrchardSprays)
dt[ , rowpos := as.factor(rowpos)]
dt[ , colpos := as.factor(colpos)]
str(dt)
dt2 <- copy(dt)
## No columns specified
convert_datatable_FactorString(dt)
str(dt)
## Specify column by position
convert_datatable_FactorString(dt2, cols=2)
str(dt2)
convert_datatable_FactorString(dt2, cols="colpos")
str(dt2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.