Desktop Survival Guide
by Graham Williams

Remove Levels from a Factor

Some tools will attempt to model all levels in an output variable. If there are no entities in the dataset with a value for one of the levels of an output variable, the tool will fail (e.g., randomForest). To remove unused levels from a factor:

> dataset$Target <- dataset$Target[,drop=TRUE]

Copyright © 2004-2006
Support further development through the purchase of the PDF version of the book.
Brought to you by Togaware.