Description Usage Arguments Value Examples
Remove empty levels from all the factor columns of a data.table object
1 | removeEmptyLevelsDT(inputDT)
|
inputDT |
data.table object containing the data of interest. This is an obligatory argument, without default value. |
No value is returned.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | library(data.table)
inputDT <- as.data.table(data.frame(x = seq(1, 20, 2), y = LETTERS[1:10]))
asFactorDT(inputDT, c('y'))
levels(inputDT$y)
removeEmptyLevelsDT(inputDT)
levels(inputDT$y)
removeEmptyLevelsDT(inputDT[x < 10])
levels(inputDT$y)
# You need to define a new data.table object
# in order to make the 'removeEmptyLevelsDT' function work.
reducedDT <- inputDT[x < 10]
levels(reducedDT$y)
removeEmptyLevelsDT(reducedDT)
levels(reducedDT$y)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.