Description Usage Arguments Value Examples
Setting the reference level of all or a selected set of the factor columns of a data.table object
1 | setRefLevelDT(inputDT, categoricalVar, referenceLevel)
|
inputDT |
data.table object containing the data of interest. This is an obligatory argument, without default value. |
categoricalVar |
Character vector containing potential column names of the 'inputDT' argument. This is an obligatory argument, without default value. |
referenceLevel |
Character vector containing the new reference levels. This is an obligatory argument, without default value. |
No value is returned. Note that the 'categoricalVar' and 'referenceLevel' should match up, meaning that they should be of the same length and the ith element should refer to the same variable.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | library(data.table)
inputDT <- as.data.table(data.frame(x = LETTERS[11:20], y = LETTERS[1:10]))
asFactorDT(inputDT, c('x', 'y'))
setRefLevelDT(inputDT)
levels(inputDT$x)[1]
levels(inputDT$y)[1]
setRefLevelDT(inputDT, c('x', 'y'), c('L', 'C'))
levels(inputDT$x)[1]
levels(inputDT$y)[1]
setRefLevelDT(inputDT, c('x', 'y'), c('bla', 'bla'))
inputDT <- as.data.table(data.frame(x = seq(1, 20, 2), y = LETTERS[1:10]))
asFactorDT(inputDT, c('y'))
levels(inputDT$y)[1]
setRefLevelDT(inputDT, 'y', 'E')
levels(inputDT$y)[1]
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.