defactor: Convert a factor into integers using 0-based indexing

View source: R/defactor_refactor.R

defactorR Documentation

Convert a factor into integers using 0-based indexing

Description

Convert a factor (or an object that can be converted as such) into an vector of integers indexed from 0 (instead of 1 as usual in R). This is what xgboost expects as input for classification tasks.

Usage

defactor(x)

Arguments

x

vector of class factor (or character).

Value

A vector of integers encoding factors, starting at 0.

Examples

defactor(factor(c("a", "b", "a")))

jiho/joml documentation built on Dec. 6, 2023, 5:50 a.m.