You can use a couple of R packages to build classification trees. Under the hood, they all do the same thing.
If you do not already have the
caret packages, install them now. Download the data files for this chapter from the book's website and place the
banknote-authentication.csv file in your R working directory.
This recipe shows you how you can use the
rpart package to build classification trees and the
rpart.plot package to generate nice-looking tree diagrams:
> library(rpart) > library(rpart.plot) > library(caret)
> bn <- read.csv("banknote-authentication.csv")