Description Usage Arguments Value Examples
Fast converting from factors to numeric/integers
1 |
DT |
The data.table to operate on |
cols |
Quoted column names |
class |
Which class to convert to: integer or numeric? |
removecomma |
Should remove commas? |
The modified data.table with the refactored columns
1 2 3 4 5 6 7 8 9 10 11 12 | set.seed(123)
DT <- data.table(x = factor(sample(10)),
y = factor(sample(10) + round(runif(10), 3)),
z = factor(paste(sample(10), round(runif(10, 100, 1000), 3), sep = ",")),
l = factor(paste(sample(10), round(runif(10, 100, 1000), 3), sep = ",")))
DT
str(DT)
factonum(DT, "x", "integer")
factonum(DT, "y")
factonum(DT, c("z", "l"), removecomma = TRUE)
str(DT)
DT
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.