View source: R/defactor_refactor.R
refactor | R Documentation |
Convert a 0-based indexed vector, which is the output of xgboost for classification, into an R factor.
refactor(x, levels)
x |
vector of integers representing a factor, with 0-based indexing. |
levels |
levels of the factor to recreate, given in order. |
A vector of class factor
xf <- factor(c("a", "b", "a"))
xi <- defactor(xf)
xi
xf2 <- refactor(xi, levels=c("a", "b"))
identical(xf, xf2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.