data(sleep)
sleepx <- sleep
sleepx$Pred <- as.factor(LETTERS[sleepx$Pred])
sleepx$Pred[1] <- NA
# a numeric and a factor target imputed at once; nrounds = 30 keeps the
# example fast (the default is 100 boosting rounds)
imp <- xgboostImpute(Dream + Pred ~ BodyWgt + BrainWgt, data = sleepx, nrounds = 30)
head(imp)
Run the code above in your browser using DataLab