Learn R Programming

yaImpute (version 1.0-15)

addXlevels: Adds xlevels to randomForest objects

Description

This function adds xlevels (see lm) to randomForest objects. Function AsciiGridImpute will check the levels on the input maps to insure that only those used in the fitting are used in the predictions. Note that this function is not needed for objects built using randomForest version 4.5-21 or later.

Usage

addXlevels(object,origDataFrame)

Arguments

object
an object built by randomForest
origDataFrame
the data frame used in the randomForest fit.

Value

  • An object of class randomForest with xlevels appended.

See Also

yai and AsciiGridPredict

Examples

Run this code
if (require(randomForest))
{
  data(iris)
  rf = randomForest(x=iris[,2:5],y=iris[,1])
  new = addXlevels(rf,iris)
  print(new$xlevels)
  predict(new)
}

Run the code above in your browser using DataLab