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 © Togaware Pty Ltd
Support further development through the purchase of the PDF version of the book.
The PDF version is a formatted comprehensive draft book (with over 800 pages).
Brought to you by Togaware. This page generated: Sunday, 22 August 2010